Skip to content

Commit

Permalink
Ensure exceptions flwo back correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaanstra committed Jan 14, 2022
1 parent 5c1b45b commit 3024806
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,29 @@ public override void Send(SendOrPostCallback d, object state)
else
{
var m = new ManualResetEvent(false);
ExceptionDispatchInfo edi = null;

m_dispatcherQueue.TryEnqueue(() =>
{
d(state);
m.Set();
try
{
d(state);
}
catch (Exception ex)
{
edi = ExceptionDispatchInfo.Capture(ex);
}
finally
{
m.Set();
}
});
m.WaitOne();

if (edi != null)
{
edi.Throw();
}
}
}

Expand Down

0 comments on commit 3024806

Please sign in to comment.