コード例 #1
0
        /// <summary>
        /// Enables deadlock detection.
        /// </summary>
        public static void Enable()
        {
            // Switch out the default TaskScheduler. We must use reflection because it is private.
            FieldInfo defaultTaskScheduler = typeof(TaskScheduler).GetField("s_defaultTaskScheduler", BindingFlags.NonPublic | BindingFlags.Static);
            DeadlockDetectionTaskScheduler newTaskScheduler = new DeadlockDetectionTaskScheduler();
            defaultTaskScheduler.SetValue(null, newTaskScheduler);

            s_threadDueTimes = new ConcurrentDictionary<Thread, ThreadInfo>();
            s_deadlockWatchdog = new Timer(CheckForDeadlocks, null, _watchdogIntervalMs, _watchdogIntervalMs);

            s_isEnabled = true;
        }
コード例 #2
0
        /// <summary>
        /// Enables deadlock detection.
        /// </summary>
        public static void Enable()
        {
            // Switch out the default TaskScheduler. We must use reflection because it is private.
            FieldInfo defaultTaskScheduler = typeof(TaskScheduler).GetField("s_defaultTaskScheduler", BindingFlags.NonPublic | BindingFlags.Static);
            DeadlockDetectionTaskScheduler newTaskScheduler = new DeadlockDetectionTaskScheduler();

            defaultTaskScheduler.SetValue(null, newTaskScheduler);

            s_threadDueTimes   = new ConcurrentDictionary <Thread, ThreadInfo>();
            s_deadlockWatchdog = new Timer(CheckForDeadlocks, null, _watchdogIntervalMs, _watchdogIntervalMs);

            s_isEnabled = true;
        }