using System; using System.Threading; using System.Threading.Tasks; using System.Linq; //using BCG.Utilities; //using BCG.Utilities.General; namespace BCG { class PubSub2Main { /// /// The main entry point for the application. /// [STAThread] public static void Main(string[] args) { bool run_echo_tcp_server_only = false; bts.utils.BTSNativeMethods.provide_command_line(new string[] { }, 0); mbts.config.Configuration.initialize(); if (run_echo_tcp_server_only) { Console.WriteLine("Running as TCP Echo server, Hit enter to continue"); Console.ReadLine(); SimpleTCPServer sts = new SimpleTCPServer(12345); sts.init(); Task.Delay(1000000000).Wait(); } if (args.Length > 0 && args[0] == "daemon") args = args.Skip(1).ToArray(); //CoreServicesInit.init(); PubSub3Config config = PubSub3Config.instance; long currentMemory = 0; int defaultWaitTime = 100; bool gced = false; new Thread(() => { while (true) { gced = false; currentMemory = GC.GetTotalMemory(false); if (config.PS3_GCActivationThreshold > 0 && currentMemory > config.PS3_GCActivationThreshold) { string gcMsg = String.Format("GCing memory, mem before GC = {0}", currentMemory); // BlueEventLog.logEvent(gcMsg, PS3LogLevels.info); Console.WriteLine(gcMsg); GC.Collect(); gced = true; } Thread.Sleep(gced ? config.PS3_WaitPeriodAfterGC : defaultWaitTime); } }).Start(); PubSubMessageReactor pubSubServer = new PubSubMessageReactor(); pubSubServer.start(); } } }