public int Run() { Log = Log ?? Loggy.Default; while (true) { try { _context.Write("> "); var command = _context.ReadLine(); if (string.IsNullOrWhiteSpace(command)) { continue; } if (command == "sync") { CheckTasks(true); continue; } if (command == "exit" || command == "quit") { try { CheckTasks(true); } catch { } return(0); } CheckTasks(); var task = Call(command); PendingTasks.Add(task); Thread.Sleep(10); CheckTasks(); Console.WriteLine(); } catch (AggregateException ae) { Log.Error(ae.InnerExceptions.FirstOrDefault()); } catch (Exception e) { Log.Error(e); } } }