public static Original.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( Original.WaitHandle waitObject, Original.WaitOrTimerCallback callBack, object state, TimeSpan ts, bool executeOnlyOnce) { return(RegisterWaitForSingleObjectHelper(waitObject, callBack, state, (long)ts.TotalMilliseconds, executeOnlyOnce, false)); }
public static Original.RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( Original.WaitHandle waitObject, Original.WaitOrTimerCallback callBack, object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce) { return(RegisterWaitForSingleObjectHelper(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce, false)); }
static Original.RegisteredWaitHandle RegisterWaitForSingleObjectHelper( Original.WaitHandle waitObject, Original.WaitOrTimerCallback callBack, object state, long millisecondsTimeOutInterval, bool executeOnlyOnce, bool isSafe) { return(Helper.SimpleWrap <Original.RegisteredWaitHandle>( delegate(ClrSyncManager manager) { Helper.WaitOrTimerCallbackRoutineArg p = new Helper.WaitOrTimerCallbackRoutineArg(); p.s = new Original::Semaphore(0, 1); p.a = new AutoResetEvent(false); p.waitObject = waitObject; p.callback = callBack; p.state = state; p.millisecondsTimeOutInterval = millisecondsTimeOutInterval; p.executeOnlyOnce = executeOnlyOnce; p.canceled = false; p.onCancellation = null; p.finished = false; Original.RegisteredWaitHandle returnValue = isSafe ? Original.ThreadPool.RegisterWaitForSingleObject(new AutoResetEvent(true), RegisterWaitHelper.RegisterWaitForSingleObjectWrapper(manager), p, Timeout.Infinite, true) : Original.ThreadPool.UnsafeRegisterWaitForSingleObject(new AutoResetEvent(true), RegisterWaitHelper.RegisterWaitForSingleObjectWrapper(manager), p, Timeout.Infinite, true); if (returnValue != null) { p.a.WaitOne(); manager.rwhToInfo[returnValue] = p; ChessTask child = manager.TaskFork(); manager.RegisterTaskSemaphore(child, p.s, false); manager.TaskResume(child); } return returnValue; }, delegate() { return isSafe ? Original.ThreadPool.RegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce) : Original.ThreadPool.UnsafeRegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce); } )); }