Control.Invoke hangs under heavy stress

There have been reports of Control.Invoke hanging after the method completes.  This was reported by a few customers and we have fixed this.  For your reference:

ID: SRX050308605416

KB Article: 896665

The problem stems from some of the errors I describe in my previous post.  IsCompleted will be "true", but the AsyncWaitHandle will never be set.  The fix will be included in our next service pack.

A few workarounds exist:

1. Use a timeout in a loop checking IsComplete.  Such as:

while (!result.IsCompleted) {

   result.AsyncWaitHandle.WaitOne(200, false);


2. Access AsyncWaitHandle and call Thread.MemoryBarrier() before checking IsComplete

WaitHandle handle = result.AsyncWaitHandle;


if (!result.IsCompleted) {



instead of:

if (!result.IsCompleted) {



Both of these workarounds should work.  The first has a minor perf implication.

Props to Jack Cheng at VideoTechnics for helping to correct the second fix.

Skip to main content