diff --git a/samples/Previewer/MainWindow.xaml.cs b/samples/Previewer/MainWindow.xaml.cs
index c72b1f7e55..8eabf44bc3 100644
--- a/samples/Previewer/MainWindow.xaml.cs
+++ b/samples/Previewer/MainWindow.xaml.cs
@@ -39,7 +39,7 @@ namespace Previewer
}));
new BsonTcpTransport().Listen(IPAddress.Loopback, 25000, t =>
{
- Dispatcher.UIThread.InvokeAsync(() =>
+ Dispatcher.UIThread.Post(() =>
{
if (_connection != null)
{
@@ -61,7 +61,7 @@ namespace Previewer
private void OnMessage(IAvaloniaRemoteTransportConnection transport, object obj)
{
- Dispatcher.UIThread.InvokeAsync(() =>
+ Dispatcher.UIThread.Post(() =>
{
if (transport != _connection)
return;
diff --git a/samples/RemoteTest/Program.cs b/samples/RemoteTest/Program.cs
index dce168c7ea..f518e77143 100644
--- a/samples/RemoteTest/Program.cs
+++ b/samples/RemoteTest/Program.cs
@@ -25,7 +25,7 @@ namespace RemoteTest
var transport = new BsonTcpTransport();
transport.Listen(IPAddress.Loopback, port, sc =>
{
- Dispatcher.UIThread.InvokeAsync(() =>
+ Dispatcher.UIThread.Post(() =>
{
new RemoteServer(sc).Content = new MainView();
});
@@ -34,7 +34,7 @@ namespace RemoteTest
var cts = new CancellationTokenSource();
transport.Connect(IPAddress.Loopback, port).ContinueWith(t =>
{
- Dispatcher.UIThread.InvokeAsync(() =>
+ Dispatcher.UIThread.Post(() =>
{
var window = new Window()
{
diff --git a/src/Avalonia.Base/AvaloniaObject.cs b/src/Avalonia.Base/AvaloniaObject.cs
index 17e6ea8f0f..a46d567d28 100644
--- a/src/Avalonia.Base/AvaloniaObject.cs
+++ b/src/Avalonia.Base/AvaloniaObject.cs
@@ -774,7 +774,7 @@ namespace Avalonia
}
else
{
- Dispatcher.UIThread.InvokeAsync(Set);
+ Dispatcher.UIThread.Post(Set);
}
}
diff --git a/src/Avalonia.Base/PriorityBindingEntry.cs b/src/Avalonia.Base/PriorityBindingEntry.cs
index b44b845f25..570bfe03dc 100644
--- a/src/Avalonia.Base/PriorityBindingEntry.cs
+++ b/src/Avalonia.Base/PriorityBindingEntry.cs
@@ -123,7 +123,7 @@ namespace Avalonia
}
else
{
- Dispatcher.UIThread.InvokeAsync(Signal);
+ Dispatcher.UIThread.Post(Signal);
}
}
@@ -135,7 +135,7 @@ namespace Avalonia
}
else
{
- Dispatcher.UIThread.InvokeAsync(() => _owner.Completed(this));
+ Dispatcher.UIThread.Post(() => _owner.Completed(this));
}
}
}
diff --git a/src/Avalonia.Base/Threading/AvaloniaScheduler.cs b/src/Avalonia.Base/Threading/AvaloniaScheduler.cs
index f9d67470c1..46529f0a5a 100644
--- a/src/Avalonia.Base/Threading/AvaloniaScheduler.cs
+++ b/src/Avalonia.Base/Threading/AvaloniaScheduler.cs
@@ -33,7 +33,7 @@ namespace Avalonia.Threading
if (!Dispatcher.UIThread.CheckAccess())
{
var cancellation = new CancellationDisposable();
- Dispatcher.UIThread.InvokeAsync(() =>
+ Dispatcher.UIThread.Post(() =>
{
if (!cancellation.Token.IsCancellationRequested)
{
diff --git a/src/Avalonia.Base/Threading/AvaloniaSynchronizationContext.cs b/src/Avalonia.Base/Threading/AvaloniaSynchronizationContext.cs
index 7a0249f876..6af5ab63cf 100644
--- a/src/Avalonia.Base/Threading/AvaloniaSynchronizationContext.cs
+++ b/src/Avalonia.Base/Threading/AvaloniaSynchronizationContext.cs
@@ -36,7 +36,7 @@ namespace Avalonia.Threading
///
public override void Post(SendOrPostCallback d, object state)
{
- Dispatcher.UIThread.InvokeAsync(() => d(state), DispatcherPriority.Send);
+ Dispatcher.UIThread.Post(() => d(state), DispatcherPriority.Send);
}
///
@@ -45,7 +45,7 @@ namespace Avalonia.Threading
if (Dispatcher.UIThread.CheckAccess())
d(state);
else
- Dispatcher.UIThread.InvokeTaskAsync(() => d(state), DispatcherPriority.Send).Wait();
+ Dispatcher.UIThread.InvokeAsync(() => d(state), DispatcherPriority.Send).Wait();
}
}
}
\ No newline at end of file
diff --git a/src/Avalonia.Base/Threading/Dispatcher.cs b/src/Avalonia.Base/Threading/Dispatcher.cs
index 4a096fc326..7d29a4f969 100644
--- a/src/Avalonia.Base/Threading/Dispatcher.cs
+++ b/src/Avalonia.Base/Threading/Dispatcher.cs
@@ -79,13 +79,13 @@ namespace Avalonia.Threading
public void RunJobs(DispatcherPriority minimumPriority) => _jobRunner.RunJobs(minimumPriority);
///
- public Task InvokeTaskAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
+ public Task InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
{
return _jobRunner?.InvokeAsync(action, priority);
}
///
- public void InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
+ public void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
{
_jobRunner?.Post(action, priority);
}
diff --git a/src/Avalonia.Base/Threading/IDispatcher.cs b/src/Avalonia.Base/Threading/IDispatcher.cs
index 6301015a9a..4009dcdeab 100644
--- a/src/Avalonia.Base/Threading/IDispatcher.cs
+++ b/src/Avalonia.Base/Threading/IDispatcher.cs
@@ -25,7 +25,7 @@ namespace Avalonia.Threading
/// The method.
/// The priority with which to invoke the method.
/// A task that can be used to track the method's execution.
- void InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal);
+ void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal);
///
/// Post action that will be invoked on main thread
@@ -34,6 +34,6 @@ namespace Avalonia.Threading
/// The priority with which to invoke the method.
// TODO: The naming of this method is confusing: the Async suffix usually means return a task.
// Remove this and rename InvokeTaskAsync as InvokeAsync. See #816.
- Task InvokeTaskAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal);
+ Task InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal);
}
}
\ No newline at end of file
diff --git a/src/Avalonia.Controls/Presenters/TextPresenter.cs b/src/Avalonia.Controls/Presenters/TextPresenter.cs
index 5f6b3ad4c8..d2d4151e3d 100644
--- a/src/Avalonia.Controls/Presenters/TextPresenter.cs
+++ b/src/Avalonia.Controls/Presenters/TextPresenter.cs
@@ -191,7 +191,7 @@ namespace Avalonia.Controls.Presenters
// The measure is currently invalid so there's no point trying to bring the
// current char into view until a measure has been carried out as the scroll
// viewer extents may not be up-to-date.
- Dispatcher.UIThread.InvokeAsync(
+ Dispatcher.UIThread.Post(
() =>
{
var rect = FormattedText.HitTestTextPosition(caretIndex);
diff --git a/src/Avalonia.Controls/Remote/RemoteWidget.cs b/src/Avalonia.Controls/Remote/RemoteWidget.cs
index c05aeaf970..83360a0010 100644
--- a/src/Avalonia.Controls/Remote/RemoteWidget.cs
+++ b/src/Avalonia.Controls/Remote/RemoteWidget.cs
@@ -18,7 +18,7 @@ namespace Avalonia.Controls.Remote
public RemoteWidget(IAvaloniaRemoteTransportConnection connection)
{
_connection = connection;
- _connection.OnMessage += (t, msg) => Dispatcher.UIThread.InvokeAsync(() => OnMessage(msg));
+ _connection.OnMessage += (t, msg) => Dispatcher.UIThread.Post(() => OnMessage(msg));
_connection.Send(new ClientSupportedPixelFormatsMessage
{
Formats = new[]
diff --git a/src/Avalonia.Controls/Remote/Server/RemoteServerTopLevelImpl.cs b/src/Avalonia.Controls/Remote/Server/RemoteServerTopLevelImpl.cs
index c2e6a200f9..cf4cec9268 100644
--- a/src/Avalonia.Controls/Remote/Server/RemoteServerTopLevelImpl.cs
+++ b/src/Avalonia.Controls/Remote/Server/RemoteServerTopLevelImpl.cs
@@ -46,16 +46,16 @@ namespace Avalonia.Controls.Remote.Server
{
_lastReceivedFrame = lastFrame.SequenceId;
}
- Dispatcher.UIThread.InvokeAsync(RenderIfNeeded);
+ Dispatcher.UIThread.Post(RenderIfNeeded);
}
if (obj is ClientSupportedPixelFormatsMessage supportedFormats)
{
lock (_lock)
_supportedFormats = supportedFormats.Formats;
- Dispatcher.UIThread.InvokeAsync(RenderIfNeeded);
+ Dispatcher.UIThread.Post(RenderIfNeeded);
}
if (obj is MeasureViewportMessage measure)
- Dispatcher.UIThread.InvokeAsync(() =>
+ Dispatcher.UIThread.Post(() =>
{
var m = Measure(new Size(measure.Width, measure.Height));
_transport.Send(new MeasureViewportMessage
@@ -69,7 +69,7 @@ namespace Avalonia.Controls.Remote.Server
lock (_lock)
{
if (_pendingAllocation == null)
- Dispatcher.UIThread.InvokeAsync(() =>
+ Dispatcher.UIThread.Post(() =>
{
ClientViewportAllocatedMessage allocation;
lock (_lock)
@@ -168,7 +168,7 @@ namespace Avalonia.Controls.Remote.Server
public override void Invalidate(Rect rect)
{
_invalidated = true;
- Dispatcher.UIThread.InvokeAsync(RenderIfNeeded);
+ Dispatcher.UIThread.Post(RenderIfNeeded);
}
public override IMouseDevice MouseDevice { get; } = new MouseDevice();
diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs
index fa3ecdedef..2e1c011685 100644
--- a/src/Avalonia.Controls/TreeView.cs
+++ b/src/Avalonia.Controls/TreeView.cs
@@ -250,7 +250,7 @@ namespace Avalonia.Controls
if (AutoScrollToSelectedItem)
{
- Dispatcher.UIThread.InvokeAsync(container.ContainerControl.BringIntoView);
+ Dispatcher.UIThread.Post(container.ContainerControl.BringIntoView);
}
break;
diff --git a/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs b/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs
index 535dfd700b..3c7ef86d5d 100644
--- a/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs
+++ b/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs
@@ -49,7 +49,7 @@ namespace Avalonia.DesignerSupport.Remote
// In previewer mode we completely ignore client-side viewport size
if (obj is ClientViewportAllocatedMessage alloc)
{
- Dispatcher.UIThread.InvokeAsync(() => SetDpi(new Vector(alloc.DpiX, alloc.DpiY)));
+ Dispatcher.UIThread.Post(() => SetDpi(new Vector(alloc.DpiX, alloc.DpiY)));
return;
}
base.OnMessage(transport, obj);
diff --git a/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs b/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs
index ac3438d71c..51cf1d4dde 100644
--- a/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs
+++ b/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs
@@ -140,7 +140,7 @@ namespace Avalonia.DesignerSupport.Remote
};
}
- private static void OnTransportMessage(IAvaloniaRemoteTransportConnection transport, object obj) => Dispatcher.UIThread.InvokeAsync(() =>
+ private static void OnTransportMessage(IAvaloniaRemoteTransportConnection transport, object obj) => Dispatcher.UIThread.Post(() =>
{
if (obj is ClientSupportedPixelFormatsMessage formats)
{
diff --git a/src/Avalonia.Layout/LayoutManager.cs b/src/Avalonia.Layout/LayoutManager.cs
index f8911dc036..b6b786a077 100644
--- a/src/Avalonia.Layout/LayoutManager.cs
+++ b/src/Avalonia.Layout/LayoutManager.cs
@@ -203,7 +203,7 @@ namespace Avalonia.Layout
{
if (!_queued && !_running)
{
- Dispatcher.UIThread.InvokeAsync(ExecuteLayoutPass, DispatcherPriority.Layout);
+ Dispatcher.UIThread.Post(ExecuteLayoutPass, DispatcherPriority.Layout);
_queued = true;
}
}
diff --git a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs
index 041d8f8f6b..82cc0a260d 100644
--- a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs
+++ b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs
@@ -415,7 +415,7 @@ namespace Avalonia.Rendering
if (!_updateQueued && (_dirty == null || _dirty.Count > 0))
{
_updateQueued = true;
- _dispatcher.InvokeAsync(UpdateScene, DispatcherPriority.Render);
+ _dispatcher.Post(UpdateScene, DispatcherPriority.Render);
}
Scene scene = null;
diff --git a/src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs b/src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs
index 136023c31d..c41a136bce 100644
--- a/src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs
+++ b/src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs
@@ -351,7 +351,7 @@ namespace Avalonia.Gtk3
void OnInput(RawInputEventArgs args)
{
- Dispatcher.UIThread.InvokeAsync(() => Input?.Invoke(args), DispatcherPriority.Input);
+ Dispatcher.UIThread.Post(() => Input?.Invoke(args), DispatcherPriority.Input);
}
public Point PointToClient(Point point)
diff --git a/src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs b/src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs
index daff4dd751..0db622ba13 100644
--- a/src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs
+++ b/src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs
@@ -41,7 +41,7 @@ namespace Avalonia.LinuxFramebuffer
if(_renderQueued)
return;
_renderQueued = true;
- Dispatcher.UIThread.InvokeAsync(() =>
+ Dispatcher.UIThread.Post(() =>
{
Paint?.Invoke(new Rect(default(Point), ClientSize));
_renderQueued = false;
diff --git a/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs b/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs
index e733beae27..896c91d087 100644
--- a/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs
+++ b/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs
@@ -62,7 +62,7 @@ public static class LinuxFramebufferPlatformExtensions
public TokenClosable(CancellationToken token)
{
- token.Register(() => Dispatcher.UIThread.InvokeAsync(() => Closed?.Invoke(this, new EventArgs())));
+ token.Register(() => Dispatcher.UIThread.Post(() => Closed?.Invoke(this, new EventArgs())));
}
}
diff --git a/src/OSX/Avalonia.MonoMac/TopLevelImpl.cs b/src/OSX/Avalonia.MonoMac/TopLevelImpl.cs
index 5ea7972871..667ee12fa0 100644
--- a/src/OSX/Avalonia.MonoMac/TopLevelImpl.cs
+++ b/src/OSX/Avalonia.MonoMac/TopLevelImpl.cs
@@ -107,7 +107,7 @@ namespace Avalonia.MonoMac
if (_nonUiRedrawQueued)
return;
_nonUiRedrawQueued = true;
- Dispatcher.UIThread.InvokeAsync(
+ Dispatcher.UIThread.Post(
() =>
{
lock (SyncRoot)
diff --git a/tests/Avalonia.UnitTests/ImmediateDispatcher.cs b/tests/Avalonia.UnitTests/ImmediateDispatcher.cs
index 4019e65bdf..92f64bde6f 100644
--- a/tests/Avalonia.UnitTests/ImmediateDispatcher.cs
+++ b/tests/Avalonia.UnitTests/ImmediateDispatcher.cs
@@ -14,12 +14,12 @@ namespace Avalonia.UnitTests
return true;
}
- public void InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
+ public void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
{
action();
}
- public Task InvokeTaskAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
+ public Task InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
{
action();
return Task.FromResult