RE: Thread handle & synchronization

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Jeffrey,

I want to creat custom thread pool so I can start next thread when some
active thread from pool goes sleep or finishes its execution - I can not
modify logic in threads which will be added to thread pool.
There has to be some way how to know that thread sleeps because Windows
switch execution to new thread when active thread fall asleep ... - or this
is not possible to find out in C# ?

Thank you.

""Jeffrey Tan[MSFT]"" wrote:

Hi,

Can you tell me why do you want to wait on the thread handle? The thread
handle will only signal when the thread terminates. If this is what you
wanted to know, why don't you call Thread.Join() method to wait on the
thread object until the thread terminates?

Thread handle will not signal while enterring sleep state. Also, I do not
think there is any notification for Thread.Sleep(). I would recommend you
to use AutoResetEvent for this notification/synchronization task. That is,
you may set AutoResetEvent before calling Thread.Sleep(). This will notify
other threads of the Thread.Sleep() calling. Another solution is polling
the thread state as Pete stated.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



.



Relevant Pages

  • RE: multithreaded tcp/ip server large page file
    ... Programming the Thread Pool in the .NET Framework ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Async Pages and Thread Pools
    ... Microsoft MSDN Online Support Lead ... concurrent requests exceeds the number of available request-processing ... threads in the thread pool. ...
    (microsoft.public.dotnet.framework)
  • I encounter the same error, but my data does not have the benefit of record tags.
    ... Microsoft Online Community Support ... You can send feedback directly to my manager at: ... where an initial response from the community or a Microsoft Support ... I am having trouble creating one input flat file. ...
    (microsoft.public.biztalk.general)
  • Where & How : GDI+ 1.1 for Visual_Studio_2008
    ... I can not find any reference for it in the Platform SDK. ... Version 1.1 in only distributed with Windows VISTA. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.win32.programmer.gdi)
  • RE: POPUp - VB.Net
    ... how does your timer interact with the threads in your ... Private Sub Button1_Click(ByVal sender As System.Object, ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vsnet.general)