Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Download Visual Studio Add-In

WaitForDebugEvent (kernel32)

C# Signature:

[DllImport( "kernel32.dll", EntryPoint = "WaitForDebugEvent" )]
[return : MarshalAs( UnmanagedType.Bool )]
public static extern bool WaitForDebugEvent(ref DEBUG_EVENT lpDebugEvent, uint dwMilliseconds );

User-Defined Types:



Wrapping WaitForDebugEvent is very hard, because you need to wrap DEBUG_EVENT, which is a large tagged variant structure. It's especially hard to make the wrappers work on both 32-bit and 64-bit because DEBUG_EVENT has different definitions on each platform.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Alternative Managed API:

The Managed Debugger (MDbg) sample has a great set of wrappers for the native debug API that deal with problems like these.

See for a quick example of what the wrappers look like.

You can download Mdbg at and get the wrappers there.

(or if that link gets broken, you can find the latest info at

In contrast, if you are trying to do managed-debugging (instead of just write a native debugger in C#), you need to use the managed debugging APIs (ICorDebug) instead of the native debugging APIs here.


Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version