Skip to content

Commit 3024806

Browse files
committed
Ensure exceptions flwo back correctly.
1 parent 5c1b45b commit 3024806

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/Projections/Reunion/Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.cs

+19-2
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,29 @@ public override void Send(SendOrPostCallback d, object state)
3434
else
3535
{
3636
var m = new ManualResetEvent(false);
37+
ExceptionDispatchInfo edi = null;
38+
3739
m_dispatcherQueue.TryEnqueue(() =>
3840
{
39-
d(state);
40-
m.Set();
41+
try
42+
{
43+
d(state);
44+
}
45+
catch (Exception ex)
46+
{
47+
edi = ExceptionDispatchInfo.Capture(ex);
48+
}
49+
finally
50+
{
51+
m.Set();
52+
}
4153
});
4254
m.WaitOne();
55+
56+
if (edi != null)
57+
{
58+
edi.Throw();
59+
}
4360
}
4461
}
4562

0 commit comments

Comments
 (0)