private static void WaitForJob(IntPtr completionEvent)
{
const int INFINITE = -1;
switch (WaitForSingleObject(completionEvent, INFINITE))
{
case WAIT_RESULT.WAIT_OBJECT_0:
// Expected result, do nothing.
break;
case WAIT_RESULT.WAIT_FAILED:
throw new Win32Exception();
default:
throw new Exception("Unexpected result when waiting for the print job.");
}
}