Re: Safe multithreading in ASP.Net
From: John Saunders (johnwsaundersiii_at_notcoldmail.com)
Date: 08/06/04
- Previous message: John Saunders: "Re: DataSet across more than 1 page"
- In reply to: who be dat?: "Safe multithreading in ASP.Net"
- Next in thread: Chris R. Timmons: "Re: Safe multithreading in ASP.Net"
- Reply: Chris R. Timmons: "Re: Safe multithreading in ASP.Net"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 6 Aug 2004 04:33:45 -0400
"who be dat?" <whatever@dot.com> wrote in message
news:10h5vp3hujp9452@corp.supernews.com...
> Consider the following code which enables multithreading in an ASP.Net
> application I'm writing:
...
> Suggestions?
Yes. I suggest that you immediately cease all idea of using multithreading
with ASP.NET! Pretend that threads just don't exist, or that any attempt to
use threads with ASP.NET will cause horrible problems for you (which is
true).
Now, since nobody ever listens to such simple-minded suggestions, I'll try
to explain. On every request, ASP.NET instantiates your Page object,
processes it in several phases, then destroys it. Nothing that was on the
page will remain after the request completes. This makes it very hard on any
threads you've started during the request, if they do not terminate before
the request terminates, as they will be operating on a dead page.
The request will not wait for your threads. It doesn't have any idea that
they exist. The fact that your threads still exist and are still referencing
objects you created on the page will not save you - the objects may still
exist, but their state may invalid. This especially goes for any objects
created or manipulated by ASP.NET, since ASP.NET believes that the request
is over, and so is unlikely to continue to maintain the state of any objects
which belong to it.
I strongly recommend that you learn some of the details of what ASP.NET is
doing behind the scenes. Take a look at the following MSDN articles:
The ASP.NET Page Object Model
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/htm
l/aspnet-pageobjectmodel.asp?frame=true)
Developing ASP.NET Server Controls
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht
ml/cpconkeyconceptsinwebformscontroldevelopment.asp)
-- John Saunders johnwsaundersiii at hotmail
- Previous message: John Saunders: "Re: DataSet across more than 1 page"
- In reply to: who be dat?: "Safe multithreading in ASP.Net"
- Next in thread: Chris R. Timmons: "Re: Safe multithreading in ASP.Net"
- Reply: Chris R. Timmons: "Re: Safe multithreading in ASP.Net"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|