This class will monitor the state to the application and raise events when it detects that the application is about to shutdown.
예제 #1
0
        public ThreadContainerThreadpool(Action <CallbackArgs> callback, Action disposeAndWaitCallback, bool disposeOnShutdown)
            : base(callback, disposeAndWaitCallback, disposeOnShutdown)
        {
            if (disposeOnShutdown)
            {
                ShutdownHandler.TryRegisterCallback(Shutdown);
            }

            m_waitObject = new ManualResetEvent(false);
        }
예제 #2
0
        public ThreadContainerDedicated(Action <CallbackArgs> callback, Action disposeAndWaitCallback, bool isBackground, ThreadPriority priority, bool disposeOnShutdown)
            : base(callback, disposeAndWaitCallback, disposeOnShutdown)
        {
            m_isBackground = isBackground;
            if (disposeOnShutdown || !isBackground)
            {
                ShutdownHandler.TryRegisterCallback(Shutdown);
            }

            m_shouldReRunImmediately  = false;
            m_shouldReRunAfterDelay   = false;
            m_threadPausedWaitHandler = new ManualResetEvent(false);
            m_threadSleepWaitHandler  = new ManualResetEvent(false);
            m_thread = new Thread(ThreadLoop);
            m_thread.IsBackground = isBackground;
            m_thread.Priority     = priority;
            m_thread.Start();
        }