TryRegisterCallback() public static method

Attempts Registers a callback that will be called when the application is shutdown.
public static TryRegisterCallback ( System.Action callback, ShutdownHandlerOrder shutdownOrder = ShutdownHandlerOrder.Default ) : bool
callback System.Action the callback when the shutdown occurs
shutdownOrder ShutdownHandlerOrder the order that the callback will occur.
return bool
Esempio n. 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);
        }
Esempio n. 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();
        }