コード例 #1
0
        public void Dispose()
        {
            try
            {
                AsyncLocker locker = Interlocked.Exchange(ref this.locker, null);

                if (locker == null)
                {
#if DEBUG
                    Debug.WriteLine($"Double free of lock detected. Maybe you disposed the {nameof(LockReleaser)} manualy inside using block?");
#endif
                }
                else
                {
                    locker?.Release();
                }
            }
            catch (NullReferenceException)
            {
#if DEBUG
                Debug.WriteLine($"Double free of lock detected. Maybe you disposed the {nameof(LockReleaser)} manualy inside using block?");
#endif
            }
        }
コード例 #2
0
 public LockReleaser(AsyncLocker locker)
 {
     this.locker = locker;
 }