internal void Wait(object state)
{
try
{
WaitHandle[] waits = new WaitHandle[] { _waitObject, _cancelEvent };
do
{
int signal = WaitHandle.WaitAny(waits, _timeout, false);
if (!_unregistered)
{
lock (this)
{
_callsInProcess++;
}
ThreadPool.QueueUserWorkItem(new WaitCallback(DoCallBack), (signal == WaitHandle.WaitTimeout));
}
}while (!_unregistered && !_executeOnlyOnce);
}
catch {}
lock (this)
{
_unregistered = true;
if (_callsInProcess == 0 && _finalEvent != null)
{
NativeEventCalls.SetEvent_internal(_finalEvent.Handle);
}
}
}