Win UI 3 System.NullReferenceException error when try to use dispatcher

Viewed 18

Hello i'm trying to update the UI from a background thread using the dispatcher but i always get this error.

System.NullReferenceException: "Object reference not set to an instance of an object."

I already tried different ways to update the UI but none worked.

My code:

DispatcherQueue dispatcherQueue = DispatcherQueue.GetForCurrentThread();
dispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal, () => { statusText.Text = "Status: Initializing..."; });
0 Answers
Related