private void AddThreadPoolInfo(Contexts contexts) { ThreadPool.GetMinThreads(out var minWorkerThreads, out var minCompletionPortThreads); ThreadPool.GetMaxThreads(out var maxWorkerThreads, out var maxCompletionPortThreads); ThreadPool.GetAvailableThreads(out var availableWorkerThreads, out var availableCompletionPortThreads); contexts[ThreadPoolInfoKey] = new ThreadPoolInfo( minWorkerThreads, minCompletionPortThreads, maxWorkerThreads, maxCompletionPortThreads, availableWorkerThreads, availableCompletionPortThreads); }
private void Log() { try { List <InfoHandleRecordStatistics> stats = this.diagnosticsViewer.GetCustomizeInfoStatistics(); ThreadPoolInfo tpi = this.diagnosticsViewer.GetThreadPoolInfo(); List <InfoHandleRecord> uncommittedInfos = this.diagnosticsViewer.GetUncommittedCustomizeInfos(); this.agileLogger.LogWithTime(string.Format("线程情况:WorkThreadCount={0}/{1}, IocpThreadCount={2}/{3}", tpi.AvailableWorkThreadCount, tpi.MaxWorkThreadCount, tpi.AvailableIocpThreadCount, tpi.MaxIocpThreadCount)); if (stats.Count > 0) { this.agileLogger.LogWithTime("历史记录:"); foreach (InfoHandleRecordStatistics stat in stats) { this.agileLogger.LogWithTime(string.Format("InformationType={0}, InformationStyle={1}, CallCount={2}, ExceptionCount={3}", stat.InformationType, stat.InformationStyle, stat.CallCount, stat.ExceptionCount)); foreach (InfoHandleRecord rcd in stat.LastRecords) { this.agileLogger.LogWithTime(string.Format(" ID={0}, StartTime={1}, TimeSpent={2}", rcd.ID, rcd.StartTime, rcd.TimeSpent)); } } } if (uncommittedInfos.Count > 0) { this.agileLogger.LogWithTime("正在处理中的消息:"); foreach (InfoHandleRecord record in uncommittedInfos) { this.agileLogger.LogWithTime(string.Format("ID={0}, InformationType={1}, InfoStyle={2}, StartTime={3}", record.ID, record.InformationType, record.InformationStyle, record.StartTime)); } } this.agileLogger.LogWithTime(""); this.agileLogger.LogWithTime("------------------ ------------------ ------------------ ------------------ "); this.agileLogger.LogWithTime(""); } catch (Exception ex) { this.agileLogger.Log(ex, "DignosticLogger.Log", ErrorLevel.Standard); } finally { } }