private static void EnterMonitorAndTryCode(object helper)
        {
            ExecuteWithLockHelper helper2 = (ExecuteWithLockHelper)helper;

            Monitor.Enter(helper2.m_lockObject, ref helper2.m_tookLock);
            helper2.m_userCode(helper2.m_userState);
        }
        private static void ExitMonitorOnBackout(object helper, bool exceptionThrown)
        {
            ExecuteWithLockHelper helper2 = (ExecuteWithLockHelper)helper;

            if (helper2.m_tookLock)
            {
                Monitor.Exit(helper2.m_lockObject);
            }
        }
        private static void EnterMonitorAndTryCode(Object helper)
        {
            ExecuteWithLockHelper execHelper = (ExecuteWithLockHelper)helper;

            BCLDebug.Assert(execHelper != null, "ExecuteWithLockHelper is null");
            BCLDebug.Assert(execHelper.m_lockObject != null, "LockObject is null");
            BCLDebug.Assert(execHelper.m_userCode != null, "UserCode is null");

            Monitor.ReliableEnter(execHelper.m_lockObject, ref execHelper.m_tookLock);
            execHelper.m_userCode(execHelper.m_userState);
        }
        private static void ExitMonitorOnBackout(Object helper, bool exceptionThrown)
        {
            ExecuteWithLockHelper execHelper = (ExecuteWithLockHelper)helper;

            BCLDebug.Assert(execHelper != null, "ExecuteWithLockHelper is null");
            BCLDebug.Assert(execHelper.m_lockObject != null, "LockObject is null");

            if (execHelper.m_tookLock)
            {
                Monitor.Exit(execHelper.m_lockObject);
            }
        }
        internal static void ExecuteCodeWithLock(Object lockObject, TryCode code, object userState)
        {
            ExecuteWithLockHelper execHelper = new ExecuteWithLockHelper(lockObject, code, userState);

            ExecuteCodeWithGuaranteedCleanup(s_EnterMonitor, s_ExitMonitor, execHelper);
        }
 internal static void ExecuteCodeWithLock(object lockObject, TryCode code, object userState)
 {
     ExecuteWithLockHelper userData = new ExecuteWithLockHelper(lockObject, code, userState);
     ExecuteCodeWithGuaranteedCleanup(s_EnterMonitor, s_ExitMonitor, userData);
 }