I
isbat1
Seems like a lot of people have trouble with this error. Here's my
solution. I give it to the future. Because I love you.
private void WaitAll(WaitHandle[] waitHandles) {
if (Thread.CurrentThread.ApartmentState == ApartmentState.STA) {
// WaitAll for multiple handles on an STA thread is not supported.
// ...so wait on each handle individually.
foreach(WaitHandle myWaitHandle in waitHandles) {
WaitHandle.WaitAny(new WaitHandle[]{myWaitHandle});
}
}
else {
WaitHandle.WaitAll(waitHandles);
}
}
solution. I give it to the future. Because I love you.
private void WaitAll(WaitHandle[] waitHandles) {
if (Thread.CurrentThread.ApartmentState == ApartmentState.STA) {
// WaitAll for multiple handles on an STA thread is not supported.
// ...so wait on each handle individually.
foreach(WaitHandle myWaitHandle in waitHandles) {
WaitHandle.WaitAny(new WaitHandle[]{myWaitHandle});
}
}
else {
WaitHandle.WaitAll(waitHandles);
}
}