MultiThreading

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Muralidharan Ramakrishnan

    MultiThreading

    Hi,

    I am trying to run a complex report in my asp.net application. The method
    which executes the report runs in a SEPERATE thread from threadpool other
    than the main application thread.

    The New thread calls a sub called ExecuteReport Which has the following code

    Sub ExecuteReport [this sub runs on seperate thread from threadpool]
    <do all report tasks>
    RaiseEvent ReportComplete
    end sub

    The Reportcomplete is the event I declared in the report class to notify the
    aspx page when the report is complete. I made the page auto post back itself
    every 2 mins to check whether this event has fired.

    The reportcomplete event is fired as intended. I have the handler to capture
    this event in asp.net page. I am trying to modify some asp.net server
    control properties when this event is fired, but nothing happens. Eg:- I
    have my report viewer visible false till then, once this event fires i set
    ReportViewer.vi sible=true but it does not happen.

    I guess it is the new thread that is launching this event and not the main
    thread, hence my controls are not getting updated properly. What I must to
    do launch this event using app Main thread once the report processing is
    complete.

    In windows controls we can use Invoke and Invoke required to safely access
    controls from threads, how is it done in ASP.net?

    Your Help will be much appreciated.

    Thanks and Regards
    Murali


  • Kevin Spencer

    #2
    Re: MultiThreading

    I'm totally confused by your question. A Page that posts back to itself is
    not the same instance of the Page class with each PostBack. It is rebuilt
    from scratch. So there's no way to set off a thread in an instance of a Page
    class, and handle the event that is raised by the class that is running in a
    spearate thread from a completely new and different instance of a Page
    class. In fact, how is a Page class that is brand new and exists for a few
    milliseconds going to even listen for the event?

    The only way to achieve what you're talking about is to cache a class
    somewhere that persists across Page instances and PostBacks, such as Session
    State, have that instance call the Thread, and then handle the event raised
    by the Thread. Page classes from that Session can then poll the cached
    instance of the class to find out whether the event was already fired and
    handled.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer

    Big Things are made up of
    Lots of Little Things.

    "Muralidhar an Ramakrishnan" <rammuraly@yaho o.co.uk> wrote in message
    news:up3j6P4pDH A.2588@tk2msftn gp13.phx.gbl...[color=blue]
    > Hi,
    >
    > I am trying to run a complex report in my asp.net application. The method
    > which executes the report runs in a SEPERATE thread from threadpool other
    > than the main application thread.
    >
    > The New thread calls a sub called ExecuteReport Which has the following[/color]
    code[color=blue]
    >
    > Sub ExecuteReport [this sub runs on seperate thread from threadpool]
    > <do all report tasks>
    > RaiseEvent ReportComplete
    > end sub
    >
    > The Reportcomplete is the event I declared in the report class to notify[/color]
    the[color=blue]
    > aspx page when the report is complete. I made the page auto post back[/color]
    itself[color=blue]
    > every 2 mins to check whether this event has fired.
    >
    > The reportcomplete event is fired as intended. I have the handler to[/color]
    capture[color=blue]
    > this event in asp.net page. I am trying to modify some asp.net server
    > control properties when this event is fired, but nothing happens. Eg:- I
    > have my report viewer visible false till then, once this event fires i set
    > ReportViewer.vi sible=true but it does not happen.
    >
    > I guess it is the new thread that is launching this event and not the main
    > thread, hence my controls are not getting updated properly. What I must[/color]
    to[color=blue]
    > do launch this event using app Main thread once the report processing is
    > complete.
    >
    > In windows controls we can use Invoke and Invoke required to safely access
    > controls from threads, how is it done in ASP.net?
    >
    > Your Help will be much appreciated.
    >
    > Thanks and Regards
    > Murali
    >
    >[/color]


    Comment

    Working...