Exemple #1
0
 /// <summary>Locks the specified object and returns an IDisposable that can be used to release the lock.</summary>
 /// <param name="monitor">The object on which to acquire the monitor lock.</param>
 /// <returns>An IDisposable that can be used to release the lock.</returns>
 public static IDisposable Lock(object monitor)
 {
     if (monitor == null) throw new ArgumentNullException("monitor");
     IDisposable cookie = new DdMonitorCookie(monitor);
     Enter(monitor);
     return cookie;
 }
Exemple #2
0
        /// <summary>Locks the specified object and returns an IDisposable that can be used to release the lock.</summary>
        /// <param name="monitor">The object on which to acquire the monitor lock.</param>
        /// <returns>An IDisposable that can be used to release the lock.</returns>
        public static IDisposable Lock(object monitor)
        {               //If we're not syncing, don't do anything
            if (m_bNoSync)
            {
                return(null);
            }

            if (monitor == null)
            {
                throw new ArgumentNullException("monitor");
            }
            IDisposable cookie = new DdMonitorCookie(monitor);

            if (!Enter(monitor))
            {
                return(null);
            }
            return(cookie);
        }
Exemple #3
0
        /// <summary>Locks the specified object and returns an IDisposable that can be used to release the lock.</summary>
        /// <param name="monitor">The object on which to acquire the monitor lock.</param>
        /// <returns>An IDisposable that can be used to release the lock.</returns>
        public static IDisposable Lock(object monitor)
        {
            //If we're not syncing, don't do anything
            if (m_bNoSync)
                return null;

            if (monitor == null) throw new ArgumentNullException("monitor");
            IDisposable cookie = new DdMonitorCookie(monitor);
            if (!Enter(monitor))
                return null;
            return cookie;
        }