olá pessoal,
Tenho um seguinte teste assíncrono:
|
[TestMethod()] |
public void TesteAsynchronous() |
{ |
using (ManualResetEvent manualResetEvent = new ManualResetEvent(false)) |
{ |
WaitCallback waitCallback = |
(state) => |
{ |
Assert.AreEqual("ERRO", state); |
manualResetEvent.Set(); |
}; |
|
ThreadPool.QueueUserWorkItem(waitCallback, "TESTE"); |
manualResetEvent.WaitOne(); |
} |
} |
Quando rodo esse teste o visual studio mostra a seguinte menssagem:
"VSTestHost.exe has stopped working
A problem caused the program to stop working correctly."
Eu já até achei uma solução:
[TestMethod()] |
public void TesteAsynchronous() |
{ |
bool areEqual = false; |
using (ManualResetEvent manualResetEvent = new ManualResetEvent(false)) |
{ |
WaitCallback waitCallback = |
(state) => |
{ |
areEqual = "ERRO".Equals(state); |
manualResetEvent.Set(); |
}; |
|
ThreadPool.QueueUserWorkItem(waitCallback, "TESTE"); |
manualResetEvent.WaitOne(); |
Assert.IsTrue(areEqual); |
} |
} |
Existe uma forma mais elegante para se tratar métodos assíncronos no Visual Studio Team System 2008?
Obrigado Mateus Bahis Vieira.
![]()