public static void TryWaitOnHandleAndDispose(ref System.Threading.WaitHandle handle)
        {
            if (object.ReferenceEquals(handle, NilWaitHandle))
            {
                return;
            }

            try
            {
                handle.WaitOne();
            }
            catch (System.ObjectDisposedException)
            {
                return;
            }
            catch (System.Exception ex)
            {
                //Should just return? (At least document that it will throw and how to catch or ignore)
                TaggedExceptionExtensions.TryRaiseTaggedException(handle, "An exception occured while waiting.", ex);
            }
            finally
            {
                if (object.ReferenceEquals(handle, NilWaitHandle).Equals(false))
                {
                    handle.Dispose();
                }
            }

            handle = null;
        }
        public static void TryWaitOnHandleAndDispose(ref System.Threading.WaitHandle handle)
        {
            if (handle == null)
            {
                return;
            }

            try
            {
                handle.WaitOne();
            }
            catch (System.ObjectDisposedException)
            {
                return;
            }
            catch (System.Exception ex)
            {
                Media.Common.Extensions.Exception.ExceptionExtensions.TryRaiseTaggedException(handle, "An exception occured while waiting.", ex);
            }
            finally
            {
                if (handle != null)
                {
                    handle.Dispose();
                }
            }

            handle = null;
        }
Example #3
0
 public static void Close(this System.Threading.WaitHandle handle)
 {
     handle.Dispose();
 }