Results 1 to 3 of 3

Thread: Threading

  1. #1
    Join Date
    Dec 1969
    Indianapolis, IN

    Default Threading

    I&#039;m trying to understand whether threading can work in ASP.NET or not. I have seen this MSDN article:, but I&#039;m having difficulty in using .ashx files. I&#039;m trying to do this based around VB.NET rather than C#. <BR><BR>This is simply for testing purposes right now so that I can keep it in mind in case I have need. My basic test case is to have a page with 2 frames. Frame 1 will contain a page which sleeps for 2 seconds, reads from a document, then either does a server.transfer back to itself or redirects to another page. Frame 2 allows the user to write to the document that Frame 1 looks at. I want Frame 1 to be in its own thread so that even though it is processing on the server, Frame 2 will finish loading and let the user interact with it regardless of what the page in Frame 1 is doing. <BR><BR>If this isn&#039;t the idea behind threading on ASP.NET, does someone have a better example? Also, does anyone have a page that explains things clearly enough in VB.NET terms (for ASP.NET mind you - nothing that is strictly VB.NET)? <BR><BR>Or is there an even better method I&#039;m unaware of for having a page constantly check to see if a document has been updated and then doing something when it has been updated without having the page refresh set to 1 second? (I&#039;d hate to cripple the network.)

  2. #2

    Default RE: Threading

    The pages may already be served by different threads. "ASP.NET is no exception and uses multiple threads within each worker process to service requests"<BR><BR>If you have multiple web servers, the probablity gets even higher. The request might be served from a different thread on different machine.<BR><BR>There is no really good way to poll the server for changes, the best you can do is making the polling not too frequent and very lightweight/fast/efficient.<BR><BR><BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default Big mistake!

    You should *NEVER* sleep a web server thread. IIS only allocates so many threads to service any number of users (its settable, but I think the default is 10 to 20). That&#039;s so that the CPU won&#039;t do "thread thrashing" with too many threads. Say the number is 20. And you have 100 users (or 50 users if each has two frames...each page counts!). So if they all hit at nearly the same time, IIS will parcel them out to the 20 threads on a sort of round-robin basis. (No, I don&#039;t know the algorithm used; suffice to say it&#039;s pretty damned good since you normally don&#039;t know it&#039;s happening.) If you hold up a thread for 2 seconds, you are holding up ALL THE PAGES SITTING IN THE QUEUE! <BR><BR>Okay, if you don&#039;t do this often and your site is lightly loaded...ehhh...go for it. <BR><BR>But in general, you should do your sleeping ON THE CLIENT! Let the client frame sleep for 2 seconds before hitting the server. (1) The thread for that frame on the client isn&#039;t doing anything anyway. (2) Better to waste the thread on the client than on the server.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts