Exemplo n.º 1
0
            public string GetFormattedStackTrace()
            {
                if (m_timeThread == null)
                {
                    return(Util.GetFormattedStackTraceFrom(null));
                }

                lock (m_lockObject)
                {
                    return(Util.GetFormattedStackTraceFrom(m_timeThread));
                }
            }
Exemplo n.º 2
0
            /// <summary>
            /// Stops the time manager if not stopped already
            /// </summary>
            /// <returns>success</returns>
            public bool Stop()
            {
                if (m_timeThread == null)
                {
                    return(false);
                }

                lock (m_lockObject)
                {
                    m_running = false;

                    if (!m_timeThread.Join(10000))
                    {
                        try
                        {
                            if (log.IsErrorEnabled)
                            {
                                ThreadState state = m_timeThread.ThreadState;
                                log.ErrorFormat("failed to stop the time thread \"{0}\" in 10 seconds (thread state={1}); thread stacktrace:\n", m_name, state);
                                log.ErrorFormat(Util.GetFormattedStackTraceFrom(m_timeThread));
                                log.ErrorFormat("aborting the thread.\n");
                            }
                        }
                        finally
                        {
                            m_timeThread.Interrupt();
                            try
                            {
                                while (!m_timeThread.Join(2000))
                                {
                                    log.ErrorFormat("Timer Thread ({0}) can't stop after abort... maybe remaining threads going... trying again !");

                                    try
                                    {
                                        m_timeThread.Interrupt();
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }

                    m_timeThread = null;

                    Array.Clear(m_buckets, 0, m_buckets.Length);
                    Array.Clear(m_cachedBucket, 0, m_cachedBucket.Length);

#if MonitorCallbacks
                    try
                    {
                        m_delayLog.Flush();
                        m_delayLog.Close();
                    }
                    catch (Exception e)
                    {
                        log.Error("Closing delays log while stop() " + m_name, e);
                    }
#endif
                    return(true);
                }
            }