public static int Initialize() { try { Task.Run(() => { while (true) { if (IsBreakPushed()) { IsBreakEnabled = !IsBreakEnabled; Console.WriteLine($"Break mode: {IsBreakEnabled}."); Thread.Sleep(1000); Entities.Clear(); } } }); var guiThread = new Thread(() => { var window = new GUIWindow(); window.ShowDialog(); }); guiThread.SetApartmentState(ApartmentState.STA); guiThread.Start(); Task.Run(() => { while (true) { if (!IsBreakEnabled) { Support(); } } }); Task.Run(() => { while (true) { if (!IsBreakEnabled) { Targetting(); } } }); } catch (Exception e) { Console.WriteLine(e); } return(1); }