Skip to content

Commit c99b1d1

Browse files
authored
Merge pull request #609 from IbraheemOsama/AwaitableRunAsyncBug
Fixing Dispatcher.AwaitableRunAsync Null problem
2 parents 5cfa872 + 803e7ff commit c99b1d1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Microsoft.Toolkit.Uwp/Helpers/DispatcherHelper.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,16 @@ public static Task<T> AwaitableRunAsync<T>(this CoreDispatcher dispatcher, Func<
165165
{
166166
try
167167
{
168-
taskCompletionSource.SetResult(await function().ConfigureAwait(false));
168+
var awaitableResult = function();
169+
if (awaitableResult != null)
170+
{
171+
var result = await awaitableResult.ConfigureAwait(false);
172+
taskCompletionSource.SetResult(result);
173+
}
174+
else
175+
{
176+
taskCompletionSource.SetResult(default(T));
177+
}
169178
}
170179
catch (Exception e)
171180
{

0 commit comments

Comments
 (0)