Click here to Skip to main content
15,896,111 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Previous Page Problem Pin
Not Active12-Feb-08 11:39
mentorNot Active12-Feb-08 11:39 
GeneralRe: Previous Page Problem Pin
waheed awan12-Feb-08 14:47
waheed awan12-Feb-08 14:47 
GeneralRe: Previous Page Problem Pin
levonh200320-May-08 7:26
levonh200320-May-08 7:26 
GeneralProblem with ListView and Request.QueryString [modified] Pin
foahchon11-Feb-08 12:54
foahchon11-Feb-08 12:54 
GeneralRe: Problem with ListView and Request.QueryString Pin
dojohansen12-Feb-08 2:23
dojohansen12-Feb-08 2:23 
QuestionInternal ASP.NET threading model Pin
dojohansen11-Feb-08 7:26
dojohansen11-Feb-08 7:26 
GeneralRe: Internal ASP.NET threading model Pin
ToddHileHoffer11-Feb-08 8:15
ToddHileHoffer11-Feb-08 8:15 
GeneralRe: Internal ASP.NET threading model Pin
dojohansen11-Feb-08 23:26
dojohansen11-Feb-08 23:26 
Hi Todd,

I'm afraid you've misunderstood. The CallContext is not for sharing information between threads, but between objects participating in the same thread. ASP.NET itself uses it to provide access to the "intrinsic" objects Request, Response, Server, Handler, Session and so on.

The main reason we can't use asp.net intrinsics such as Session or Application state is that our business layer runs in a non-web context as well. Specifically, we have a windows service that implements a scheduler. This being .net, there should be no problem using the same business layer in the web app and the service, but this of course means the business layer cannot rely on anything asp.net specific.

Another reason is that we perform many long-running tasks which cannot be performed in a synchronous "request - do the work - create the response" manner, but must instead use one request to start work, then go into polling until the work is finished, then get the results. So another reason to avoid relying on the web context is that it enables us to provide identical execution contexts in the threads our code creates as well as those created by asp.net, so business logic can be developed without having to know in advance whether it will take part in "background" threads or not. We keep only a small amount of information here, but it is absolutely essential: The identity of the user, and database connection information. (It is a distributed system and a single application instance can connect to any number of database instances, while also any number of application instances can connect to any given database instance. Hence we need to know on a user-by-user basis what database the user is "logged on to", though we do of course use connection pooling.)

Not using session or app state of course doesn't automatically imply using the CallContext, but it is extremely convenient because it provides isolation between threads, and also because references put into it are removed when the thread ends, so clean-up is automatic much in the same way as with local variables that simply go out of scope.

If anyone has the inside knowledge to answer my actual question rather than try to second-guess what I'm asking (no offense, I appreciate the attempt!) then please let me know. I'm really quite convinced though that it is the same logical thread: asp.net events happen in stages and I can see no reason why one would want to complicate matters by switching threads along the way, when the processing anyway must occur in a linear fashion.
GeneralRe: Internal ASP.NET threading model Pin
dojohansen11-Feb-08 23:31
dojohansen11-Feb-08 23:31 
GeneralRe: Internal ASP.NET threading model Pin
ToddHileHoffer12-Feb-08 1:31
ToddHileHoffer12-Feb-08 1:31 
GeneralRe: Internal ASP.NET threading model Pin
dojohansen12-Feb-08 2:12
dojohansen12-Feb-08 2:12 
GeneralRe: Internal ASP.NET threading model Pin
ToddHileHoffer12-Feb-08 2:22
ToddHileHoffer12-Feb-08 2:22 
GeneralRe: Internal ASP.NET threading model Pin
dojohansen12-Feb-08 3:00
dojohansen12-Feb-08 3:00 
GeneralRe: Internal ASP.NET threading model Pin
ToddHileHoffer12-Feb-08 3:16
ToddHileHoffer12-Feb-08 3:16 
QuestionRequest is not available in this context Pin
Ryno Burger11-Feb-08 6:34
Ryno Burger11-Feb-08 6:34 
GeneralRe: Request is not available in this context Pin
dojohansen11-Feb-08 7:49
dojohansen11-Feb-08 7:49 
GeneralRe: Request is not available in this context Pin
Not Active11-Feb-08 7:59
mentorNot Active11-Feb-08 7:59 
Generalneed regular expression of a strict (999) 999-9999 Format Pin
Rocky#11-Feb-08 6:05
Rocky#11-Feb-08 6:05 
AnswerRe: need regular expression of a strict (999) 999-9999 Format Pin
dilipv11-Feb-08 19:41
dilipv11-Feb-08 19:41 
GeneralRe: need regular expression of a strict (999) 999-9999 Format Pin
Rocky#11-Feb-08 19:52
Rocky#11-Feb-08 19:52 
GeneralASP.NET C# Mifare Reader Web System Pin
Tyrone Boon11-Feb-08 5:57
Tyrone Boon11-Feb-08 5:57 
GeneralCross Post Pin
led mike11-Feb-08 6:18
led mike11-Feb-08 6:18 
Generaloutlook in asp.net Pin
i gr811-Feb-08 3:50
i gr811-Feb-08 3:50 
GeneralRe: outlook in asp.net Pin
Not Active11-Feb-08 5:09
mentorNot Active11-Feb-08 5:09 
GeneralRe: outlook in asp.net Pin
i gr811-Feb-08 7:48
i gr811-Feb-08 7:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.