System.Runtime.InteropServices.SafeHandle.DangerousRelease C# (CSharp) Method

DangerousRelease() private method

private DangerousRelease ( ) : void
return void
		public void DangerousRelease ()
		{
			if (refcount <= 0)
				throw new ObjectDisposedException (GetType ().FullName);

			int newcount, current;
			do {
				current = refcount;
				newcount = current-1;
			} while (Interlocked.CompareExchange (ref refcount, newcount, current) != current);

			if (newcount == 0 && owns_handle && !IsInvalid){
				ReleaseHandle ();
				handle = invalid_handle_value;
			}
		}

Usage Example

Ejemplo n.º 1
0
      public static ArbitraryWaitHandle FromSafeHandle(SafeHandle safeHandle) {
         Contract.Requires(safeHandle != null);
         Boolean success = false;
         try {
            safeHandle.DangerousAddRef(ref success);
            if (!success) throw new InvalidOperationException("Couldn't AddRef");

            return new ArbitraryWaitHandle(safeHandle.DangerousGetHandle());
         }
         finally {
            safeHandle.DangerousRelease();
         }
      }
All Usage Examples Of System.Runtime.InteropServices.SafeHandle::DangerousRelease