You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's not widely known that Dispatcher is effectively deprecated (not sure why it hasn't been marked as such) and that it's better to use DispatcherQueue instead. We made this change in the Windows Community Toolkit a while ago now. It's well supported and it means a seemlesss transition for those pieces to the Windows App SDK and WinUI 3.
We should have an analyzer and codefix which detects the old usage and swaps it out for DispatcherQueue instead.
We'd probably need to inject a private variable and set in the constructor to ensure the most compatible fix.
// MainPage.xaml.cs in a UWP apppublicvoidNotifyUser(stringstrMessage){if(this.Dispatcher.HasThreadAccess){StatusBlock.Text=strMessage;}else{vartask=this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,()=>StatusBlock.Text=strMessage);}}
Expected:
// MainPage.xaml.cs in a Windows App SDK apppublicvoidNotifyUser(stringstrMessage){if(this.DispatcherQueue.HasThreadAccess){StatusBlock.Text=strMessage;}else{boolisQueued=this.DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal,()=>StatusBlock.Text=strMessage);}}
Should handle both the DP usage of Dispatcher as well as the CoreWindow general one.
Should also handle more complex cases where the containing type doesn't have a DispatcherQueue?
The text was updated successfully, but these errors were encountered:
Related to #6
See:
It's not widely known that Dispatcher is effectively deprecated (not sure why it hasn't been marked as such) and that it's better to use DispatcherQueue instead. We made this change in the Windows Community Toolkit a while ago now. It's well supported and it means a seemlesss transition for those pieces to the Windows App SDK and WinUI 3.
We should have an analyzer and codefix which detects the old usage and swaps it out for DispatcherQueue instead.
We'd probably need to inject a private variable and set in the constructor to ensure the most compatible fix.
Expected:
Should handle both the DP usage of Dispatcher as well as the CoreWindow general one.
Should also handle more complex cases where the containing type doesn't have a DispatcherQueue?
The text was updated successfully, but these errors were encountered: