【发布时间】:2020-01-02 23:56:06
【问题描述】:
我们有一个带有ThreadPool 和WaitHandle 的旧版应用程序。我们想针对它使用 MSTest 编写单元测试。我们遇到了一个问题,默认情况下 MSTest 在 STA(单线程单元)模式下运行并且测试抛出以下异常,
System.NotSupportedException:STA 上的多个句柄的 WaitAll 不支持线程。在 System.Threading.WaitHandle.WaitMultiple(WaitHandle[] waitHandles, Int32 毫秒超时,布尔型 exitContext,布尔型 WaitAll)在 System.Threading.WaitHandle.WaitAll(WaitHandle[] waitHandles, Int32 毫秒超时,布尔退出上下文)在 System.Threading.WaitHandle.WaitAll(WaitHandle[] waitHandles, TimeSpan 超时,布尔exitContext)
【问题讨论】: