WaitForSingleObject (kernel32)
Last changed: -186.136.223.176

.
Summary

C# Signature:

[DllImport("kernel32", SetLastError=true, ExactSpelling=true)]
  internal static extern Int32 WaitForSingleObject(IntPtr handle, Int32 milliseconds);

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

  public static uint INFINITE = 0xFFFFFFFF;

and use:

  WaitForSingleObject(handle, (int)INFINITE);

Edgar - edgarrc(at)gmail.com

Sample Code:

private void Run()

{

  while (bRunning)
  {
      try
      {
      if(WaitForSingleObject(ReceivedEvent,INFINITE) == WAIT_OBJECT_0
     {
         // Signaled            
         DoSomething();
     }
       }
       catch(Exception Ex)
       {
       // We raise the Stop to Read event
      //
      trhow(Ex);
       }
  }

}

Alternative Managed API:

If you're waiting on a file system object, look at System.IO.FileSystemWatcher

Documentation