From d3cde7cc8273b5607543f88b115e2c4f8f78d0a6 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 11 May 2020 22:29:49 +0300 Subject: [PATCH] Removed duplicated code --- .../Rendering/ManagedDeferredRendererLock.cs | 42 +------------------ 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/src/Avalonia.Visuals/Rendering/ManagedDeferredRendererLock.cs b/src/Avalonia.Visuals/Rendering/ManagedDeferredRendererLock.cs index 90d0120ea9..158fecbfc6 100644 --- a/src/Avalonia.Visuals/Rendering/ManagedDeferredRendererLock.cs +++ b/src/Avalonia.Visuals/Rendering/ManagedDeferredRendererLock.cs @@ -6,46 +6,6 @@ namespace Avalonia.Rendering { public class ManagedDeferredRendererLock : DisposableLock, IDeferredRendererLock { - private readonly object _lock = new object(); - - /// - /// Tries to lock the target surface or window - /// - /// IDisposable if succeeded to obtain the lock - public IDisposable TryLock() - { - if (Monitor.TryEnter(_lock)) - return new UnlockDisposable(_lock); - return null; - } - - /// - /// Enters a waiting lock, only use from platform code, not from the renderer - /// - public IDisposable Lock() - { - Monitor.Enter(_lock); - return new UnlockDisposable(_lock); - } - - private sealed class UnlockDisposable : IDisposable - { - private object _lock; - - public UnlockDisposable(object @lock) - { - _lock = @lock; - } - - public void Dispose() - { - object @lock = Interlocked.Exchange(ref _lock, null); - - if (@lock != null) - { - Monitor.Exit(@lock); - } - } - } + } }