Skip to content

Commit 45a90fa

Browse files
committed
Removed unnecessary API presence check
1 parent 130dbe0 commit 45a90fa

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

Microsoft.Toolkit.Uwp/Helpers/DispatcherQueueHelper.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using System;
66
using System.Threading.Tasks;
7-
using Windows.Foundation.Metadata;
87
using Windows.System;
98

109
namespace Microsoft.Toolkit.Uwp.Helpers
@@ -32,7 +31,7 @@ public static Task ExecuteOnUIThreadAsync(this DispatcherQueue dispatcher, Actio
3231
/* Run the function directly when we have thread access.
3332
* Also reuse Task.CompletedTask in case of success,
3433
* to skip an unnecessary heap allocation for every invocation. */
35-
if (HasThreadAccess(dispatcher))
34+
if (dispatcher.HasThreadAccess)
3635
{
3736
try
3837
{
@@ -81,7 +80,7 @@ public static Task<T> ExecuteOnUIThreadAsync<T>(this DispatcherQueue dispatcher,
8180
throw new ArgumentNullException(nameof(function));
8281
}
8382

84-
if (HasThreadAccess(dispatcher))
83+
if (dispatcher.HasThreadAccess)
8584
{
8685
try
8786
{
@@ -129,7 +128,7 @@ public static Task ExecuteOnUIThreadAsync(this DispatcherQueue dispatcher, Func<
129128
* We don't use ConfigureAwait(false) in this case, in order
130129
* to let the caller continue its execution on the same thread
131130
* after awaiting the task returned by this function. */
132-
if (HasThreadAccess(dispatcher))
131+
if (dispatcher.HasThreadAccess)
133132
{
134133
try
135134
{
@@ -188,7 +187,7 @@ public static Task<T> ExecuteOnUIThreadAsync<T>(this DispatcherQueue dispatcher,
188187
throw new ArgumentNullException(nameof(function));
189188
}
190189

191-
if (HasThreadAccess(dispatcher))
190+
if (dispatcher.HasThreadAccess)
192191
{
193192
try
194193
{
@@ -230,10 +229,5 @@ public static Task<T> ExecuteOnUIThreadAsync<T>(this DispatcherQueue dispatcher,
230229

231230
return taskCompletionSource.Task;
232231
}
233-
234-
private static bool HasThreadAccess(DispatcherQueue dispatcher)
235-
{
236-
return ApiInformation.IsMethodPresent("Windows.System.DispatcherQueue", "HasThreadAccess") && dispatcher.HasThreadAccess;
237-
}
238232
}
239233
}

0 commit comments

Comments
 (0)