close

如果在程式中使用 multithreading 而且使用 waitall() ,當要做unit test時,會發

Technorati Tags: Troubleshooting,Unit Test

生 "System.NotSupportedException: 不支援 STA 執行緒上多個控制代碼的 WaitAll" 這個exception

原因:

因為Vistual Studio 的 unit test 中預設是為 STA threading model ,當使用必須是MAT model(像是WaitHandle.WaitAll)就會發生錯誤

解決方式:

修改測試回合組態(.testrunconfig)

<TestRunConfiguration ...>

...

<ExecutionThread apartmentState="MTA" />

</TestRunConfiguration>

arrow
arrow
    全站熱搜

    丫烈客 發表在 痞客邦 留言(0) 人氣()