QueueCompareProcessThread()消息的異常消息:在預期範圍內,值不會落入 。跟蹤:在 System.Threading.WaitHandle.WaitMultiple(WaitHandle的[] waitHandles, 的Int32 millisecondsTimeout,布爾exitContext,布爾爲WaitAll)在 System.Threading.WaitHandle.WaitAny(WaitHandle的[] waitHandles,的Int32 millisecondsTimeout,布爾exitContext)在 System.Threading.WaitHandle.WaitAny(WaitHandle的[] waitHandles)如何防止此異常:值不在預期的範圍內。用WaitHandle.WaitAny方法?
我得到上述當我使用上的WaitHandle
的WaitAny
方法在一個線程的異常。請幫我解決這個問題。這裏是我的部分代碼:
public void QueueCompareProcessThread(QueueProcesses Qp)
{
try
{
WaitHandle[] pHandles = Qp.GetRunningProcessesHandles();
WaitHandle.WaitAny(pHandles);
Qp.RemoveExitedProcess(); // clearing the process list
// strange behavior is while clearing the process list i'm getting the exception in the thread Waitany method
// Does Waitany method still working after it returns?
}
catch (Exception e)
{
utils.Log("QProc Exception at QueueCompareProcessThread() Message:" + e.Message + " Trace:" + e.StackTrace);
}
}
誰能請提供有關了WaitAny方法的一些想法,幫我理清問題?
如果您記錄'ex.ToString()'而不是僅記錄消息和堆棧跟蹤,它會有很大幫助。目前,您在日誌中缺少異常類型。如果知道例外類型,可以在[documentation](https://msdn.microsoft.com/en-us/library/tdykks7z(v = vs.110).aspx)中查找問題的具體內容。 –