static void runall(MethodInfo Target, object[] obj, object parentInstance, TestingWindow Window) { IAsyncTesting at = null; if (parentInstance != null && parentInstance is IAsyncTesting) { at = (IAsyncTesting)parentInstance; Window.WriteLine("Method supports async commands. You can write"); } var th = new Thread(asyncRun); th.Start(); var wth = new Thread(asyncWriting); wth.Start(); if (th != null && th.IsAlive) { th.Join(); } try { wth.Abort(); } catch { } Window.EndRead(); void asyncRun() { Window.WriteLine($"\nInvoking \"{Target.Name}\" with params: \n\t{string.Join("\n\t", obj)}\n\t"); Target.Invoke(parentInstance, obj); Window.WriteLine($"\nEnd of \"{Target.Name}\" invoke."); } void asyncWriting() { while (th != null && th.IsAlive) { try { parseComm(Window.ReadLine(), Window, th, at); } catch (ThreadAbortException) { } catch (Exception ex) { Window.WriteLine($"Error during execution command: {ex.Message}"); } } } }