public static void Initialize() { // Initialize logs instance GCLatencyMode oldMode = GCSettings.LatencyMode; RuntimeHelpers.PrepareConstrainedRegions(); GCSettings.LatencyMode = GCLatencyMode.Batch; ServicePointManager.DefaultConnectionLimit = int.MaxValue; Scheduler = new NetScheduler(Settings.Instance.Model.ThreadCount); PPScheduler = new PostprocessorScheduler(Settings.Instance.Model.PostprocessorThreadCount); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); }
public static bool Initialize() { if (Initialized) { Logs.Instance.Push("App provider already initialized!"); return(true); } // Initialize logs instance Logs.Instance.Push("App provider initializing..."); // Check program crashed. if (ProgramLock.ProgramCrashed) { Logs.Instance.Push("Program is terminated abnormally."); } #if DEBUG // Check exists instances. if (Instance.Count > 1) { throw new Exception("You must wait for app-provider initialization procedure before using instance-lazy!\n" + "For more informations, see the development documents."); } #endif // GC Setting GCLatencyMode oldMode = GCSettings.LatencyMode; RuntimeHelpers.PrepareConstrainedRegions(); GCSettings.LatencyMode = GCLatencyMode.Batch; // Extends Connteion Limit ServicePointManager.DefaultConnectionLimit = int.MaxValue; // Initialize Scheduler Scheduler = new NetScheduler(Settings.Instance.Model.ThreadCount); // Initialize Postprocessor Scheduler PPScheduler = new PostprocessorScheduler(Settings.Instance.Model.PostprocessorThreadCount); Logs.Instance.Push("App provider starts."); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); Initialized = true; return(true); }
static void Main(string[] args) { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); GCLatencyMode oldMode = GCSettings.LatencyMode; RuntimeHelpers.PrepareConstrainedRegions(); GCSettings.LatencyMode = GCLatencyMode.Batch; ServicePointManager.DefaultConnectionLimit = int.MaxValue; Scheduler = new NetScheduler(Settings.Instance.Model.ThreadCount); PPScheduler = new PostprocessorScheduler(Settings.Instance.Model.PostprocessorThreadCount); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); #if DEBUG ChatBot.BotManager.Instance.StartBots(); while (true) { System.Threading.Tasks.Task.Run(async() => await Loop.LoopInternal()); Thread.Sleep(1000 * 60 * 10); } #endif try { Command.Start(args); } catch (Exception e) { Console.WriteLine("An error occured! " + e.Message); Console.WriteLine(e.StackTrace); Console.WriteLine("Please, check log.txt file."); } Environment.Exit(0); }