diff --git a/src/Avalonia.Base/Threading/Dispatcher.cs b/src/Avalonia.Base/Threading/Dispatcher.cs index aa2a7a7a8e..55a9b6984a 100644 --- a/src/Avalonia.Base/Threading/Dispatcher.cs +++ b/src/Avalonia.Base/Threading/Dispatcher.cs @@ -92,6 +92,20 @@ namespace Avalonia.Threading return _jobRunner.InvokeAsync(function, priority); } + /// + public Task InvokeAsync(Func function, DispatcherPriority priority = DispatcherPriority.Normal) + { + Contract.Requires(function != null); + return _jobRunner.InvokeAsync(function, priority).Unwrap(); + } + + /// + public Task InvokeAsync(Func> function, DispatcherPriority priority = DispatcherPriority.Normal) + { + Contract.Requires(function != null); + return _jobRunner.InvokeAsync(function, priority).Unwrap(); + } + /// public void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal) { diff --git a/src/Avalonia.Base/Threading/IDispatcher.cs b/src/Avalonia.Base/Threading/IDispatcher.cs index 1fdc9da5fe..8f46f99283 100644 --- a/src/Avalonia.Base/Threading/IDispatcher.cs +++ b/src/Avalonia.Base/Threading/IDispatcher.cs @@ -40,5 +40,23 @@ namespace Avalonia.Threading /// The method. /// The priority with which to invoke the method. Task InvokeAsync(Func function, DispatcherPriority priority = DispatcherPriority.Normal); + + /// + /// Queues the specified work to run on the dispatcher thread and returns a proxy for the + /// task returned by . + /// + /// The work to execute asynchronously. + /// The priority with which to invoke the method. + /// A task that represents a proxy for the task returned by . + Task InvokeAsync(Func function, DispatcherPriority priority = DispatcherPriority.Normal); + + /// + /// Queues the specified work to run on the dispatcher thread and returns a proxy for the + /// task returned by . + /// + /// The work to execute asynchronously. + /// The priority with which to invoke the method. + /// A task that represents a proxy for the task returned by . + Task InvokeAsync(Func> function, 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 3181e76c3f..a30d9bfc48 100644 --- a/src/Avalonia.Controls/Presenters/TextPresenter.cs +++ b/src/Avalonia.Controls/Presenters/TextPresenter.cs @@ -35,6 +35,11 @@ namespace Avalonia.Controls.Presenters private int _selectionEnd; private bool _caretBlink; private IBrush _highlightBrush; + + static TextPresenter() + { + AffectsRender(PasswordCharProperty); + } public TextPresenter() { @@ -49,6 +54,9 @@ namespace Avalonia.Controls.Presenters this.GetObservable(CaretIndexProperty) .Subscribe(CaretIndexChanged); + + this.GetObservable(PasswordCharProperty) + .Subscribe(_ => InvalidateFormattedText()); } public int CaretIndex diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs index 31113812d1..32b0a1f259 100644 --- a/src/Avalonia.Controls/Slider.cs +++ b/src/Avalonia.Controls/Slider.cs @@ -171,11 +171,7 @@ namespace Avalonia.Controls /// Value that want to snap to closest Tick. private void MoveToNextTick(double value) { - double next = SnapToTick(Math.Max(Minimum, Math.Min(Maximum, value))); - if (next != value) - { - Value = next; - } + Value = SnapToTick(Math.Max(Minimum, Math.Min(Maximum, value))); } /// @@ -194,4 +190,4 @@ namespace Avalonia.Controls return value; } } -} \ No newline at end of file +} diff --git a/tests/Avalonia.UnitTests/ImmediateDispatcher.cs b/tests/Avalonia.UnitTests/ImmediateDispatcher.cs index 44d8c78054..fac4ee64e7 100644 --- a/tests/Avalonia.UnitTests/ImmediateDispatcher.cs +++ b/tests/Avalonia.UnitTests/ImmediateDispatcher.cs @@ -9,28 +9,45 @@ namespace Avalonia.UnitTests /// public class ImmediateDispatcher : IDispatcher { + /// public bool CheckAccess() { return true; } + /// public void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal) { action(); } + /// public Task InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal) { action(); - return Task.FromResult(null); + return Task.CompletedTask; } + /// public Task InvokeAsync(Func function, DispatcherPriority priority = DispatcherPriority.Normal) { var result = function(); return Task.FromResult(result); } + /// + public Task InvokeAsync(Func function, DispatcherPriority priority = DispatcherPriority.Normal) + { + return function(); + } + + /// + public Task InvokeAsync(Func> function, DispatcherPriority priority = DispatcherPriority.Normal) + { + return function(); + } + + /// public void VerifyAccess() { }