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)中查找问题的具体内容。 –