question

anilchanna avatar image
0 Votes"
anilchanna asked anilchanna edited

DispatcherHelper in Windows Community Toolkit

I am working on upgrading MVVMLight to Windows Community Toolkit and facing issues with DispatcherHelper. I am unable to find any examples which can show me how to upgrade the functionality relating to DispatcherHelper. Any pointers will be really appreciated.

dotnet-csharpdotnet-wpf-xaml
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,@AnilChanna-0773 . Is your project a wpf project or a uwp project? Could you show some code and details related to your problem?

0 Votes 0 ·

Mine is WPF project developed using .Net Framework 4.5 and I am working on upgrading it to .Net 6. I am unable to understand how to use Dispatcher Helper in Windows Community Toolkit. Here is one example of the code to be modified -

         DispatcherHelper.CheckBeginInvokeOnUI(() =>
         {
             toRemove.ForEach(x => this.ProjectFiles.Remove(x));
         });
0 Votes 0 ·

Here is another example which needs to be converted -

         this.timer = new DispatcherTimer(DispatcherPriority.DataBind, DispatcherHelper.UIDispatcher)
         {
             Interval = new TimeSpan(0, 0, 1),
             IsEnabled = true
         };

I am unsure how to achieve this using Windows Community Toolkit

0 Votes 0 ·

0 Answers