Skip to content

Commit ad464d3

Browse files
committed
Core - CefThread better error handling for queued execution
1 parent 88762cb commit ad464d3

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

CefSharp/Internals/CefThread.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,17 @@ private static Task QueueForExcutionWhenUiThreadCreated(Action action)
141141
{
142142
Initialized -= handler;
143143

144-
//TODO: Should this call UiThreadTaskFactory.StartNew?
145-
action();
144+
try
145+
{
146+
//TODO: Should this call UiThreadTaskFactory.StartNew?
147+
action();
146148

147-
tcs.SetResult(true);
149+
tcs.TrySetResult(true);
150+
}
151+
catch(Exception ex)
152+
{
153+
tcs.TrySetException(ex);
154+
}
148155
};
149156

150157
Initialized += handler;
@@ -167,10 +174,17 @@ private static Task<T> QueueForExcutionWhenUiThreadCreated<T>(Func<T> func)
167174
{
168175
Initialized -= handler;
169176

170-
//TODO: Should this call UiThreadTaskFactory.StartNew?
171-
var result = func();
177+
try
178+
{
179+
//TODO: Should this call UiThreadTaskFactory.StartNew?
180+
var result = func();
172181

173-
tcs.SetResult(result);
182+
tcs.TrySetResult(result);
183+
}
184+
catch(Exception ex)
185+
{
186+
tcs.TrySetException(ex);
187+
}
174188
};
175189

176190
Initialized += handler;

0 commit comments

Comments
 (0)