waithandle

What is the difference between Thread.Sleep(timeout) and ManualResetEvent.Wait(timeout)?

Both Thread.Sleep(timeout) and resetEvent.Wait(timeout) cause execution to pause for at least timeout milliseconds, so is there a difference between them? I know that Thread.Sleep causes the thread to give up the remainder of its time slice, thus possibly resulting in a sleep that lasts far longer than asked for. Does the Wait(timeout) m...

reading txt storing in different

ASp.NET application. In button click i am accessing one text file and reading content and storing in other destination. while both users clicking this button at a time deadlock(thread is being used by other process) will occurs so how to handle this i want to read each user one by one can any one suggest method to handle. i am looking...

How do you close an application when some WaitHandle is in the middle of a call to WaitOne?

Is there a standard way to close out an application "cleanly" while some WaitHandle objects may be in the state of a current blocking call to WaitOne? For example, there may be a background thread that is spinning along in a method like this: while (_request.WaitOne()) { try { _workItem.Invoke(); } finally {...

Unit testing WaitHandler.WaitAll

Is there a way to unit test WaitHandle.WaitAll() when using Visual Studio's built-in unit testing solution. When I try and run a test that uses this function within Visual Studio the test fails and when examining the test results the following error is displayed: WaitAll for multiple handles on a STA thread is not supported I'd like...

Threadpool/WaitHandle resource leak/crash

I think I may need to re-think my design. I'm having a hard time narrowing down a bug that is causing my computer to completely hang, sometimes throwing an HRESULT 0x8007000E from VS 2010. I have a console application (that I will later convert to a service) that handles transferring files based on a database queue. I am throttling th...

How to check if the WaitHandle was set?

I have a WaitHandle and I would like to know how to check if the WaitHandle has already been set or not. Note: I can add a bool variable and whenever Set() method is used set the variable to true, but this behaviour must be built in WaitHandle somewhere. Thanks for help! ...

VB.NET Abort an asynchronous method call after timeout

VB.NET 2010, .NET 4 Hello all, I have a System.Timers.Timer object that does some work on its elapsed event: Private Sub MasterTimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles MasterTimer.Elapsed MasterTimer.Enabled = False '...work... MasterTimer.Enabled = True End Sub My problem ...