WaitForSingleObjectEx C# equivalent

  • Thread starter Thread starter Nadav
  • Start date Start date
N

Nadav

Hi,

I am using APC, this requires the usage of WaitForSingleObjectEx(... , ...
, true );
I want to use APC in C# What is the equivalent of WaitForSingleObjectEx in
C#?
**********************************************
* How should I implement the following section using C#? *
**********************************************
DWORD dwRetCode = WAIT_IO_COMPLETION;
while(WAIT_IO_COMPLETION == dwRetCode)
dwRetCode = WaitForSingleObjectEx(m_hWriting, INFINITE, TRUE);
**********************************************

Thanks,
Nadav.
 
Nadav,

In this case, you will have to make the call to WaitForSingleObjectEx
through the P/Invoke layer. The declaration you need is:

[DllImport("kernel32.dll", SetLastError=true)]
[return:MarshalAs(UnmanagedType.U4)]
public static int WaitForSingleObjectEx(
IntPtr hHandle,
[MarshalAs(UnmanagedType.U4)] int dwMilliseconds,
bool bAlertable);

Hope this helps.
 
Back
Top