From e72d6e3924e7bf1554eb62f400d27a1814a1504d Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 11 Jul 2019 07:17:14 +0300 Subject: [PATCH] Updated NameScopeLocator --- .../Controls/NameScopeLocator.cs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Avalonia.Styling/Controls/NameScopeLocator.cs b/src/Avalonia.Styling/Controls/NameScopeLocator.cs index 9cec6950e4..719cf9344b 100644 --- a/src/Avalonia.Styling/Controls/NameScopeLocator.cs +++ b/src/Avalonia.Styling/Controls/NameScopeLocator.cs @@ -31,31 +31,28 @@ namespace Avalonia.Controls private class NeverEndingSynchronousCompletionAsyncResultObservable : IObservable { private T _value; - private SynchronousCompletionAsyncResult? _task; + private SynchronousCompletionAsyncResult? _asyncResult; public NeverEndingSynchronousCompletionAsyncResultObservable(SynchronousCompletionAsyncResult task) { if (task.IsCompleted) _value = task.GetResult(); else - _task = task; + _asyncResult = task; } public IDisposable Subscribe(IObserver observer) { - if (_task?.IsCompleted == true) + if (_asyncResult?.IsCompleted == true) { - _value = _task.Value.GetResult(); - _task = null; + _value = _asyncResult.Value.GetResult(); + _asyncResult = null; } - if (_task != null) - // We expect everything to handle callbacks synchronously, - // so the object graph is ready after its built - // so keep TaskContinuationOptions.ExecuteSynchronously - _task.Value.OnCompleted(() => + if (_asyncResult != null) + _asyncResult.Value.OnCompleted(() => { - observer.OnNext(_task.Value.GetResult()); + observer.OnNext(_asyncResult.Value.GetResult()); }); else observer.OnNext(_value);