Skip to content

Commit

Permalink
fix(winui): Adjust DispatcherQueue implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Nov 5, 2021
1 parent a7c9943 commit 263f914
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 161 deletions.
9 changes: 0 additions & 9 deletions src/Uno.UI.Runtime.Skia.Gtk/GtkHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,6 @@ public void Run()
Gtk.Application.Quit();
};

bool EnqueueNative(DispatcherQueuePriority priority, DispatcherQueueHandler callback)
{
Dispatch(() => callback());

return true;
}

Windows.System.DispatcherQueue.EnqueueNativeOverride = EnqueueNative;

void Dispatch(System.Action d)
{
if (Gtk.Application.EventsPending())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ void Dispatch(System.Action d)
_eventLoop.Schedule(() => d());
}

Windows.System.DispatcherQueue.EnqueueNativeOverride = EnqueueNative;
Windows.UI.Core.CoreDispatcher.DispatchOverride = Dispatch;
Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = () => _isDispatcherThread;

Expand Down
2 changes: 0 additions & 2 deletions src/Uno.UI.Runtime.Skia.Tizen/TizenHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ bool EnqueueNative(DispatcherQueuePriority priority, DispatcherQueueHandler call
return true;
}

Windows.System.DispatcherQueue.EnqueueNativeOverride = EnqueueNative;

Windows.UI.Core.CoreDispatcher.DispatchOverride = (d) => EcoreMainloop.PostAndWakeUp(d);
Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = () => EcoreMainloop.IsMainThread;

Expand Down
2 changes: 0 additions & 2 deletions src/Uno.UI.Runtime.Skia.Wpf/WpfHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ bool EnqueueNative(DispatcherQueuePriority priority, DispatcherQueueHandler call
return true;
}

Windows.System.DispatcherQueue.EnqueueNativeOverride = EnqueueNative;

Windows.UI.Core.CoreDispatcher.DispatchOverride = d => dispatcher.BeginInvoke(d);
Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = dispatcher.CheckAccess;

Expand Down
26 changes: 0 additions & 26 deletions src/Uno.UWP/System/DispatcherQueue.Android.cs

This file was deleted.

17 changes: 13 additions & 4 deletions src/Uno.UWP/System/DispatcherQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,21 @@ internal static void CheckThreadAccess()
}

public bool TryEnqueue(DispatcherQueueHandler callback)
{
return TryEnqueue(DispatcherQueuePriority.Normal, callback);
}
=> TryEnqueue(DispatcherQueuePriority.Normal, callback);

public bool TryEnqueue(DispatcherQueuePriority priority, DispatcherQueueHandler callback)
{
return TryEnqueueNative(priority, callback);
var p = priority switch
{
DispatcherQueuePriority.Normal => CoreDispatcherPriority.Normal,
DispatcherQueuePriority.High => CoreDispatcherPriority.High,
DispatcherQueuePriority.Low => CoreDispatcherPriority.Low,
_ => CoreDispatcherPriority.Normal
};

CoreDispatcher.Main.RunAsync(p, () => callback());

return true;
}

public bool HasThreadAccess
Expand Down
26 changes: 0 additions & 26 deletions src/Uno.UWP/System/DispatcherQueue.iOSmacOS.cs

This file was deleted.

26 changes: 0 additions & 26 deletions src/Uno.UWP/System/DispatcherQueue.net.cs

This file was deleted.

18 changes: 0 additions & 18 deletions src/Uno.UWP/System/DispatcherQueue.netstdref.cs

This file was deleted.

21 changes: 0 additions & 21 deletions src/Uno.UWP/System/DispatcherQueue.skia.cs

This file was deleted.

26 changes: 0 additions & 26 deletions src/Uno.UWP/System/DispatcherQueue.wasm.cs

This file was deleted.

0 comments on commit 263f914

Please sign in to comment.