我们有一个带有ThreadPool
和的遗留应用程序WaitHandle
。我们想针对它使用MSTest编写单元测试。我们遇到了一个问题,默认情况下 MSTest 在 STA(单线程单元)模式下运行,并且测试抛出以下异常,
System.NotSupportedException:不支持 STA 线程上的多个句柄的 WaitAll。在 System.Threading.WaitHandle.WaitAll 的 System.Threading.WaitHandle.WaitMultiple(WaitHandle[] waitHandles,Int32 毫秒超时,布尔 exitContext,布尔WaitAll)在 System.Threading.WaitHandle(WaitHandle[] waitHandles,Int32 毫秒超时,布尔 exitContext)在 System.Threading.WaitHandle。 WaitAll(WaitHandle[] waitHandles,TimeSpan 超时,布尔型 exitContext)