MainThread (Xamarin.Essentials API of the Week)

Play MainThread (Xamarin.Essentials API of the Week)
Sign in to queue

Description

Xamarin.Essentials provides developers with cross-platform APIs for their mobile applications. On this week's Xamarin.Essential API of the week we take a look at the MainThread API to enable you to check if the code you are about to execute will run on the main user interface thread and a way to invoke code on the main thread if it isn't.

Show Notes:

Useful Links:

Embed

Download

The Discussion

  • User profile image
    Mikilll

    What is the difference to using Device.BeginInvokeOnMainThread() which is built directly into Xamarin.Forms?

  • User profile image
    SmartmanApps
    +1
  • User profile image
    Jeffm
    MiKill - there's a comment in the docs that addresses that....

    Xamarin.Forms has a method called Device.BeginInvokeOnMainThread(Action) that does the same thing as MainThread.BeginInvokeOnMainThread(Action). While you can use either method in a Xamarin.Forms app, consider whether or not the calling code has any other need for a dependency on Xamarin.Forms. If not, MainThread.BeginInvokeOnMainThread(Action) is likely a better option.

    https://docs.microsoft.com/en-us/xamarin/essentials/main-thread
  • User profile image
    briansavage
    Thanks James, great video, simple and to the point, as usual. How about a 101 on threading in general, perhaps async as well. I have a vague idea about how all these work, but your 101s fill in a lot of gaps.

Add Your 2 Cents