c#Custom Threading Leak和WaitHandle.WaitAny()

时间:2014-11-04 05:29:50

标签: c# multithreading

我有一个似乎泄漏的应用程序。其中一个Timers.Timer对象停止为经过事件并开始泄漏线程,如.NET 4.0 System.Timers.Timer seems to not execute the elapsed event after some time中所示。

还有其他线程,其中一些只是停止处理并显示在堆栈跟踪下方。 ~*e !clrstack

中有大约8个等待线程
Child SP IP       Call Site
07baf8f8 778f5cd4 [HelperMethodFrame_1OBJ: 07baf8f8] System.Threading.WaitHandle.WaitMultiple(System.Threading.WaitHandle[], Int32, Boolean, Boolean)
07baf9c0 70d0dd2b System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle[], Int32, Boolean)
07baf9e0 018a6129 MyDatabaseThread.threadMain()
07bafa30 018a5eee <Module>.OS.UnmanagedThreadProc(Void*)

以下是threadMain()

下的一些代码片段
WaitHandle[] waitHandles = new WaitHandle[2];
waitHandles[0] = _threadAbort;
WaitHandles[1] = _messageWaiting;
WaitHandle.WaitAny(waitHandles);

等待句柄声明如下。

private AutoResetEvent _messageWaiting;
private ManualResetEvent _threadAbort;

任何帮助将不胜感激。我无法确定导致挂断的原因。感谢

0 个答案:

没有答案