private static void LogMaxThreads() { int workerThreads; int portThreads; System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out portThreads); TraceWriter.SubmitData(new TraceDto { Message = $"MaxThreads: workerThreads({workerThreads}) portThreads({portThreads})" }); }
public static void StartApplication() { lock (_lockObject) { if (!_isApplicationStarted) { Stopwatch s = new Stopwatch(); s.Start(); StartupProject = Assembly.GetCallingAssembly(); List <Type> allTypes = GetAlltypes().ToList(); UnityDependencyInjectionManager dependencyInjectionManager = new UnityDependencyInjectionManager(allTypes); DependencyInjectionManager = dependencyInjectionManager; List <ApplicationStartBase> applicationStartInstaces = GetAllApplicationStart(allTypes).Select(type => Activator.CreateInstance(type) as ApplicationStartBase) .OrderBy(item => item.ExecutionPriorityBeforeApplicationStart).ToList(); applicationStartInstaces.ForEach(instanceType => { instanceType.BeforeApplicationStart(); }); Core.Cmn.AppBase.TraceWriter = Core.Cmn.AppBase.DependencyInjectionFactory.CreateInjectionInstance <ITraceWriter>(); TraceWriter.SubmitData(new TraceDto { Message = $"Preparing App took {s.Elapsed.TotalSeconds} seconds." }); TraceWriter.SubmitData(new TraceDto { Message = "Staring App..." }); ////LogService = Core.Cmn.AppBase.DependencyInjectionFactory.CreateInjectionInstance<ILogService>(); TraceWriter.SubmitData(new TraceDto { Message = "EntityInfo.BuildEntityInfoDic starting..." }); EntityInfo.BuildEntityInfoDic(allTypes); TraceWriter.SubmitData(new TraceDto { Message = "EntityInfo.BuildEntityInfoDic done." }); applicationStartInstaces.OrderBy(i => Convert.ToInt32(i.ExecutionPriorityOnApplicationStart)).ToList().ForEach(instance => { TraceWriter.SubmitData(new TraceDto { Message = $"{instance.GetType().FullName} starting..." }); instance.OnApplicationStart(); TraceWriter.SubmitData(new TraceDto { Message = $"{instance.GetType().FullName} done." }); }); ///The line below converts ConcurrentDictionary to Dictionary, because after building cache we never add any CacheInfo ///to our Dictionary so we did not need a ConcurrentDictionary any more for ThreadSafty. Cache.CacheConfig.CacheInfoDic = Cache.CacheConfig.CacheInfoDic.ToDictionary(item => item.Key, item => item.Value); TraceWriter.SubmitData(new TraceDto { Message = $"Is64BitProcess: {Environment.Is64BitProcess}" }); TraceWriter.SubmitData(new TraceDto { Message = $"ProcessorCount: {Environment.ProcessorCount}" }); LogMinThreads(); LogMaxThreads(); _isApplicationStarted = true; TraceWriter.SubmitData(new TraceDto { Message = $"App startup took {s.Elapsed.TotalSeconds} seconds." }); s.Stop(); } else { throw new Exception("Application can't start for second time."); } } }