private static void Main(string[] args) { if (Settings.PersistentSettings.debugConsole) { AllocConsole(); // needs to be the first call in the program to prevent weird bugs } var uriRes = IPCadapter.getInstance().HandleURIStart(args); switch (uriRes) { case URIStartResult.CLOSE: Environment.Exit(0); break; case URIStartResult.PARSE: Console.WriteLine($"Starting with args : {args[0]}"); break; case URIStartResult.CONTINUE: break; default: throw new ArgumentOutOfRangeException(); } var socket = new ClientSocket(); //Create the Form Console interface. Task.Factory.StartNew(() => socket.Init()).Wait(); // run socket in background. Important to wait for init to have actually finished before continuing var thread = new Thread(OpenGUI); thread.SetApartmentState(ApartmentState.STA); thread.Start(); while (Settings.conInterface is null) { Thread.Sleep(250); } //Create the Form Console interface. Task.Factory.StartNew(() => socket.Init()) .Wait(); // run socket in background. Important to wait for init to have actually finished before continuing IPCadapter.getInstance().RegisterMinion(); window.Loaded += (sender, eventArgs) => { Task.Factory.StartNew(() => GameMemReader.getInstance().RunLoop()); // run loop in background if (uriRes == URIStartResult.PARSE) { IPCadapter.getInstance().SendToken(args[0]); } }; thread.Join(); }
static void Main(string[] args) { if (Settings.PersistentSettings.debugConsole) { AllocConsole(); // needs to be the first call in the program to prevent weird bugs } URIStartResult uriRes = HandleURIStart(args); if (uriRes == URIStartResult.CLOSE) { return; } Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ClientSocket socket = new ClientSocket(); form = new UserForm(socket); Settings.form = form; Settings.conInterface = new FormConsole(form); //Create the Form Console interface. Task.Factory.StartNew(() => socket.Init()).Wait(); // run socket in background. Important to wait for init to have actually finished before continuing Task.Factory.StartNew(() => GameMemReader.getInstance().RunLoop()); // run loop in background Task.Factory.StartNew(() => IPCadapter.getInstance().RunLoop(uriRes == URIStartResult.PARSE ? args[0] : null)); // Run listener for tokens //AllocConsole(); Application.Run(form); //test }
/// <summary> /// The main entry point for the application. /// </summary> public static void Main() { //Create the Form Console interface. var socketTask = Task.Factory.StartNew(() => socket.Init()); // run socket in background. Important to wait for init to have actually finished before continuing Task.Factory.StartNew(() => GameMemReader.getInstance().RunLoop()); // run loop in background socketTask.Wait(); IPCadapter.getInstance().RegisterMinion(); }
private static void Main(string[] args) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Settings.PersistentSettings.debugConsole) { AllocConsole(); // needs to be the first call in the program to prevent weird bugs } if (!Directory.Exists(Settings.StorageLocation)) { // Create Settings directory if it doesn't exist, as we need to stick our pidfile there. Directory.CreateDirectory(Settings.StorageLocation); } URIStartResult uriRes = URIStartResult.CLOSE; uriRes = IPCadapter.getInstance().HandleURIStart(args); switch (uriRes) { case URIStartResult.CLOSE: Environment.Exit(0); break; case URIStartResult.PARSE: Console.WriteLine($"Starting with args : {args[0]}"); break; case URIStartResult.CONTINUE: break; default: throw new ArgumentOutOfRangeException(); } socket = new ClientSocket(); //Create the Form Console interface. var thread = new Thread(OpenGUI); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { thread.SetApartmentState(ApartmentState.STA); } thread.Start(); while (Settings.conInterface is null) { Thread.Sleep(250); } Task.Factory.StartNew(() => socket.Init()) .Wait(); // run socket in background. Important to wait for init to have actually finished before continuing Task.Factory.StartNew(() => IPCadapter.getInstance().RegisterMinion()).Wait(); // Add a GLib Idle handler to fix the issue here. Idle.Add(delegate { Task.Factory.StartNew(() => GameMemReader.getInstance().RunLoop()); // run loop in background if (uriRes == URIStartResult.PARSE) { IPCadapter.getInstance().SendToken(args[0]); } return(false); }); thread.Join(); }