GetTrace() public static method

Gets all of the callbacks for all timers.
public static GetTrace ( StringBuilder sb ) : void
sb StringBuilder
return void
Example #1
0
        private static void MonitorThreads()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("--------------------------------------------------------");
            sb.AppendLine("Thread Pool Queue");
            sb.AppendLine("--------------------------------------------------------");

            ThreadPoolTrace.GetTrace(sb);

            sb.AppendLine("--------------------------------------------------------");
            sb.AppendLine("Timers");
            sb.AppendLine("--------------------------------------------------------");

            TimerTrace.GetTrace(sb);

            //Since current builds of openPDC appears to be doing better about not blocking all threads on the threadpool
            //this diagnostics functionality has been disabled but the code has been left in place if it's needed in the future.

            //            if (OptimizationOptions.EnableThreadStackDumping)
            //            {
            //#if !MONO
            //                using (var dataTarget = DataTarget.AttachToProcess(Process.GetCurrentProcess().Id, 5000, AttachFlag.Passive))
            //                {
            //                    foreach (var clr in dataTarget.ClrVersions)
            //                    {
            //                        var runtime = clr.CreateRuntime();

            //                        sb.AppendLine("--------------------------------------------------------");
            //                        sb.AppendLine("Thread Stacks");
            //                        sb.AppendLine("--------------------------------------------------------");
            //                        foreach (var t in runtime.Threads)
            //                        {
            //                            bool hasWrittenData = false;

            //                            foreach (var item in t.StackTrace)
            //                            {
            //                                if (item.Method != null)
            //                                {
            //                                    if (!hasWrittenData)
            //                                        hasWrittenData = true;
            //                                    sb.AppendLine(item.ToString());
            //                                }
            //                            }
            //                            if (hasWrittenData)
            //                            {
            //                                sb.AppendLine("--------------------------------------------------------");
            //                            }
            //                        }
            //                    }
            //                }
            //#endif
            //            }
            Log.Publish(MessageLevel.Warning, "ThreadPool Stack Trace", "Dumped threadpool stack trace", sb.ToString());
        }