-
Notifications
You must be signed in to change notification settings - Fork 1
Performance Tips
Chris Perry edited this page Mar 19, 2024
·
1 revision
When you are able, offloading tasks from the main (UI) thread can help with the user experience. However, while doing this it's important to make sure that whenever code updates the UI, it's done on the main (UI) thread.
- Anything that directly updates the UI such as changing the property of a UI element or updating its content
- Snippets of code that depend on things other than quick logic such as database calls, API calls, or long-running calculations.
- Non-direct UI updates such as updating a property that a UI element is bound/subscribed to
The linked article below details how to run code on the UI thread. Details can be found here
More details can be found here
- Using Task.Run and other methods like it offload the passed method onto another thread
- Be sure that whenever UI elements are updated inside of these passed methods, that it uses the MainThread.BeingInvokeOnMainThread method or methods like it discussed in the How do I make something run on the main (UI) thread section