Skip to content

Commit eefd6b1

Browse files
committed
Added [Obsolete] messages to help migration
1 parent 25ed2d7 commit eefd6b1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Microsoft.Toolkit.Uwp/Helpers/DispatcherHelper.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.Toolkit.Uwp.Helpers
1212
/// <summary>
1313
/// This class provides static methods helper for executing code in UI thread of the main window.
1414
/// </summary>
15-
[Obsolete]
15+
[Obsolete("Replace calls to APIs in this class with extensions for the Windows.System.DispatcherQueue type (see https://docs.microsoft.com/uwp/api/windows.system.dispatcherqueue).")]
1616
public static class DispatcherHelper
1717
{
1818
/// <summary>
@@ -22,6 +22,7 @@ public static class DispatcherHelper
2222
/// <param name="priority">Dispatcher execution priority, default is normal.</param>
2323
/// <returns>An awaitable <see cref="Task"/> for the operation.</returns>
2424
/// <remarks>If the current thread has UI access, <paramref name="function"/> will be invoked directly.</remarks>
25+
[Obsolete("This method should be replaced with CoreApplication.MainView.DispatcherQueue.EnqueueAsync(function, priority).")]
2526
public static Task ExecuteOnUIThreadAsync(Action function, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal)
2627
{
2728
return ExecuteOnUIThreadAsync(CoreApplication.MainView, function, priority);
@@ -35,6 +36,7 @@ public static Task ExecuteOnUIThreadAsync(Action function, CoreDispatcherPriorit
3536
/// <param name="priority">Dispatcher execution priority, default is normal.</param>
3637
/// <returns>An awaitable <see cref="Task{T}"/> for the operation.</returns>
3738
/// <remarks>If the current thread has UI access, <paramref name="function"/> will be invoked directly.</remarks>
39+
[Obsolete("This method should be replaced with CoreApplication.MainView.DispatcherQueue.EnqueueAsync(function, priority).")]
3840
public static Task<T> ExecuteOnUIThreadAsync<T>(Func<T> function, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal)
3941
{
4042
return ExecuteOnUIThreadAsync(CoreApplication.MainView, function, priority);
@@ -47,6 +49,7 @@ public static Task<T> ExecuteOnUIThreadAsync<T>(Func<T> function, CoreDispatcher
4749
/// <param name="function">Asynchronous function to be executed asynchronously on UI thread.</param>
4850
/// <param name="priority">Dispatcher execution priority, default is normal.</param>
4951
/// <returns>An awaitable <see cref="Task"/> for the operation.</returns>
52+
[Obsolete("This method should be replaced with CoreApplication.MainView.DispatcherQueue.EnqueueAsync(function, priority).")]
5053
public static Task ExecuteOnUIThreadAsync(Func<Task> function, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal)
5154
{
5255
return ExecuteOnUIThreadAsync(CoreApplication.MainView, function, priority);
@@ -60,6 +63,7 @@ public static Task ExecuteOnUIThreadAsync(Func<Task> function, CoreDispatcherPri
6063
/// <param name="function">Asynchronous function to be executed asynchronously on UI thread.</param>
6164
/// <param name="priority">Dispatcher execution priority, default is normal.</param>
6265
/// <returns>An awaitable <see cref="Task{T}"/> for the operation.</returns>
66+
[Obsolete("This method should be replaced with CoreApplication.MainView.DispatcherQueue.EnqueueAsync(function, priority).")]
6367
public static Task<T> ExecuteOnUIThreadAsync<T>(Func<Task<T>> function, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal)
6468
{
6569
return ExecuteOnUIThreadAsync(CoreApplication.MainView, function, priority);
@@ -73,6 +77,7 @@ public static Task<T> ExecuteOnUIThreadAsync<T>(Func<Task<T>> function, CoreDisp
7377
/// <param name="priority">Dispatcher execution priority, default is normal</param>
7478
/// <returns>An awaitable <see cref="Task"/> for the operation.</returns>
7579
/// <remarks>If the current thread has UI access, <paramref name="function"/> will be invoked directly.</remarks>
80+
[Obsolete("This method should be replaced with viewToExecuteOn.DispatcherQueue.EnqueueAsync(function, priority).")]
7681
public static Task ExecuteOnUIThreadAsync(this CoreApplicationView viewToExecuteOn, Action function, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal)
7782
{
7883
if (viewToExecuteOn is null)
@@ -92,6 +97,7 @@ public static Task ExecuteOnUIThreadAsync(this CoreApplicationView viewToExecute
9297
/// <param name="priority">Dispatcher execution priority, default is normal.</param>
9398
/// <returns>An awaitable <see cref="Task{T}"/> for the operation.</returns>
9499
/// <remarks>If the current thread has UI access, <paramref name="function"/> will be invoked directly.</remarks>
100+
[Obsolete("This method should be replaced with viewToExecuteOn.DispatcherQueue.EnqueueAsync(function, priority).")]
95101
public static Task<T> ExecuteOnUIThreadAsync<T>(this CoreApplicationView viewToExecuteOn, Func<T> function, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal)
96102
{
97103
if (viewToExecuteOn is null)
@@ -110,6 +116,7 @@ public static Task<T> ExecuteOnUIThreadAsync<T>(this CoreApplicationView viewToE
110116
/// <param name="priority">Dispatcher execution priority, default is normal.</param>
111117
/// <returns>An awaitable <see cref="Task"/> for the operation.</returns>
112118
/// <remarks>If the current thread has UI access, <paramref name="function"/> will be invoked directly.</remarks>
119+
[Obsolete("This method should be replaced with viewToExecuteOn.DispatcherQueue.EnqueueAsync(function, priority).")]
113120
public static Task ExecuteOnUIThreadAsync(this CoreApplicationView viewToExecuteOn, Func<Task> function, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal)
114121
{
115122
if (viewToExecuteOn is null)
@@ -129,6 +136,7 @@ public static Task ExecuteOnUIThreadAsync(this CoreApplicationView viewToExecute
129136
/// <param name="priority">Dispatcher execution priority, default is normal.</param>
130137
/// <returns>An awaitable <see cref="Task"/> for the operation.</returns>
131138
/// <remarks>If the current thread has UI access, <paramref name="function"/> will be invoked directly.</remarks>
139+
[Obsolete("This method should be replaced with viewToExecuteOn.DispatcherQueue.EnqueueAsync(function, priority).")]
132140
public static Task<T> ExecuteOnUIThreadAsync<T>(this CoreApplicationView viewToExecuteOn, Func<Task<T>> function, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal)
133141
{
134142
if (viewToExecuteOn is null)
@@ -147,6 +155,7 @@ public static Task<T> ExecuteOnUIThreadAsync<T>(this CoreApplicationView viewToE
147155
/// <param name="priority">Dispatcher execution priority, default is normal.</param>
148156
/// <returns>An awaitable <see cref="Task"/> for the operation.</returns>
149157
/// <remarks>If the current thread has UI access, <paramref name="function"/> will be invoked directly.</remarks>
158+
[Obsolete("This method should be replaced with dispatcherQueue.EnqueueAsync(function, priority). A queue can be retrieved with DispatcherQueue.GetForCurrentThread().")]
150159
public static Task AwaitableRunAsync(this CoreDispatcher dispatcher, Action function, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal)
151160
{
152161
if (function is null)
@@ -199,6 +208,7 @@ public static Task AwaitableRunAsync(this CoreDispatcher dispatcher, Action func
199208
/// <param name="priority">Dispatcher execution priority, default is normal.</param>
200209
/// <returns>An awaitable <see cref="Task{T}"/> for the operation.</returns>
201210
/// <remarks>If the current thread has UI access, <paramref name="function"/> will be invoked directly.</remarks>
211+
[Obsolete("This method should be replaced with dispatcherQueue.EnqueueAsync(function, priority). A queue can be retrieved with DispatcherQueue.GetForCurrentThread().")]
202212
public static Task<T> AwaitableRunAsync<T>(this CoreDispatcher dispatcher, Func<T> function, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal)
203213
{
204214
if (function is null)
@@ -244,6 +254,7 @@ public static Task<T> AwaitableRunAsync<T>(this CoreDispatcher dispatcher, Func<
244254
/// <param name="priority">Dispatcher execution priority, default is normal.</param>
245255
/// <returns>An awaitable <see cref="Task"/> for the operation.</returns>
246256
/// <remarks>If the current thread has UI access, <paramref name="function"/> will be invoked directly.</remarks>
257+
[Obsolete("This method should be replaced with dispatcherQueue.EnqueueAsync(function, priority). A queue can be retrieved with DispatcherQueue.GetForCurrentThread().")]
247258
public static Task AwaitableRunAsync(this CoreDispatcher dispatcher, Func<Task> function, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal)
248259
{
249260
if (function is null)
@@ -307,6 +318,7 @@ public static Task AwaitableRunAsync(this CoreDispatcher dispatcher, Func<Task>
307318
/// <param name="priority">Dispatcher execution priority, default is normal.</param>
308319
/// <returns>An awaitable <see cref="Task{T}"/> for the operation.</returns>
309320
/// <remarks>If the current thread has UI access, <paramref name="function"/> will be invoked directly.</remarks>
321+
[Obsolete("This method should be replaced with dispatcherQueue.EnqueueAsync(function, priority). A queue can be retrieved with DispatcherQueue.GetForCurrentThread().")]
310322
public static Task<T> AwaitableRunAsync<T>(this CoreDispatcher dispatcher, Func<Task<T>> function, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal)
311323
{
312324
if (function is null)

0 commit comments

Comments
 (0)