Пример #1
0
        private void TryCallback(ScheduledTaskRunningReason args)
        {
            m_workerThreadID = Thread.CurrentThread.ManagedThreadId;

            try
            {
                if ((object)Running != null)
                {
                    Running(this, new EventArgs <ScheduledTaskRunningReason>(args));
                }
            }
            catch (Exception ex)
            {
                try
                {
                    if ((object)UnhandledException != null)
                    {
                        UnhandledException(this, new EventArgs <Exception>(ex));
                    }
                }
                catch (Exception ex2)
                {
                    Debug.WriteLine(ex2.ToString());
                }
            }

            if (args == ScheduledTaskRunningReason.Disposing)
            {
                try
                {
                    if ((object)Disposing != null)
                    {
                        Disposing(this, EventArgs.Empty);
                    }
                }
                catch (Exception ex)
                {
                    try
                    {
                        if ((object)UnhandledException != null)
                        {
                            UnhandledException(this, new EventArgs <Exception>(ex));
                        }
                    }
                    catch (Exception ex2)
                    {
                        Debug.WriteLine(ex2.ToString());
                    }
                }
                m_waitForDispose.Set();
                InternalDisposeAllResources();
            }

            m_workerThreadID = -1;
        }
Пример #2
0
        private void TryCallback(ScheduledTaskRunningReason args)
        {
            m_workerThreadID = Thread.CurrentThread.ManagedThreadId;

            try
            {
                if ((object)Running != null)
                    Running(this, new EventArgs<ScheduledTaskRunningReason>(args));
            }
            catch (Exception ex)
            {
                try
                {
                    if ((object)UnhandledException != null)
                        UnhandledException(this, new EventArgs<Exception>(ex));
                }
                catch (Exception ex2)
                {
                    Debug.WriteLine(ex2.ToString());
                }
            }

            if (args == ScheduledTaskRunningReason.Disposing)
            {
                try
                {
                    if ((object)Disposing != null)
                        Disposing(this, EventArgs.Empty);
                }
                catch (Exception ex)
                {
                    try
                    {
                        if ((object)UnhandledException != null)
                            UnhandledException(this, new EventArgs<Exception>(ex));
                    }
                    catch (Exception ex2)
                    {
                        Debug.WriteLine(ex2.ToString());
                    }
                }
                m_waitForDispose.Set();
                InternalDisposeAllResources();
            }

            m_workerThreadID = -1;
        }