Welcome to Webhost4life Forum Sign in | Join | Faq

ASP.NET C#

Started by chris at 03-24-2007 4:36 PM. Topic has 3 replies.

Print Search
Sort Posts:    
   03-24-2007, 4:36 PM
chris is not online. Last active: 3/25/2007 7:32:12 AM chris

Top 10 Posts
Joined on 04-20-2006
Posts 21
Multithreading
Reply Quote
    I'm trying to do some very simple multithreading on my ASP.NET 2.0 application hosted on the Advanced package on WebHost4Life. I'm using the ThreadPool like so:

            bool result = ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadProc), tt);

It works great in my local test environment but on the WH4L server it doesn't execute. The result is set to true on the return to that call back ThreadProc is never invoked. At the moment I'm not trying to do anything fancy - just writing to a log file to observe the multithreading in action and make sure that it works - or in this case doesn't work.

Anyway, has anybody used multithreading in their ASP.NET application? Does it work on WH4L servers?

I'm wondering if it's been disabled on the WH4L servers? Can you disable that sort of thing?

   Report 
   03-25-2007, 4:22 PM
chris is not online. Last active: 3/25/2007 7:32:12 AM chris

Top 10 Posts
Joined on 04-20-2006
Posts 21
Re: Multithreading
Reply Quote
I have asked this same question with more details and a code sample (if anybody wants to see what the results are and the code used) on the asp.net forum:

http://forums.asp.net/thread/1636213.aspx
   Report 
   06-10-2008, 12:45 AM
Milo is not online. Last active: 6/10/2008 3:24:29 PM Milo

Top 75 Posts
Joined on 06-10-2008
Posts 4
Re: Multithreading
Reply Quote
Have you just tried with one thread, then try two...? To make sure this IS a threading restriction.

You can restrict IIS through the Application pooling to max CPU usage (% and refresh)

Not sure how WH4L set the websites up, but I would have setup one pool, per website account and .net versions
   Report 
   07-26-2008, 5:45 AM
savant is not online. Last active: 7/26/2008 8:34:23 PM savant

Not Ranked
Joined on 07-26-2008
Posts 1
Hmm [^o)] Re: Multithreading
Reply Quote
There are settings for the .NET ThreadPool that can be set by WH4L at the server or application level, but the only way to find out reliably is by running some code inside your environment. Create an ASP.NET page, add an asp:Literal control to it with an ID of 'Results' (also remember to set 'runat=server' too), then include the following in the Page_Load event in the code-behind file:

      int workerThreads;
      int completionPortThreads;
      int maxWorkerThreads;
      int maxCompletionPortThreads;
      int minWorkerThreads;
      int minCompletionPortThreads;

      ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads);
      ThreadPool.GetMaxThreads(out maxWorkerThreads, out maxCompletionPortThreads);
      ThreadPool.GetMinThreads(out minWorkerThreads, out minCompletionPortThreads);

      Results.Text = "Available Threads: " + workerThreads.ToString() + " / " +
          completionPortThreads.ToString() +
          "<br>Max Threads: " + maxWorkerThreads.ToString() + " / " +
          maxCompletionPortThreads.ToString() +
          "<br>Min Threads: " + minWorkerThreads.ToString() + " / " +
          minCompletionPortThreads.ToString();


What this does is interrogate the ThreadPool itself to discover its settings. What I got when I ran it was 100 worker threads maximum with 99 available (obviously because the page itself is taking up one of those threads to do its own work).

If you are getting similar results, then the issue is most probably with your code.
 

   Report 
Webhost4life Fo... » General Discuss... » ASP.NET C# » Multithreading

Powered by Community Server, by Telligent Systems