MultiThreading

  • Thread starter Thread starter Muralidharan Ramakrishnan
  • Start date Start date
M

Muralidharan Ramakrishnan

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.visible=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
 
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
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
Back
Top