public static void Exit_Requested() { Task.Run(() => { string msg = "Are you sure you want to exit NebliDex?"; //Check to see if there are any pending orders that are being matched //Since Atomic Swaps are timelocked, it is not advised to leave program when actively involved in swap lock (MainService.MyOpenOrderList) { for (int i = 0; i < MainService.MyOpenOrderList.Count; i++) { if (MainService.MyOpenOrderList[i].order_stage >= 3 && MainService.MyOpenOrderList[i].is_request == false) { msg = "You are involved in a trade. If you close now, you may lose trade amount. Are you sure you want to exit NebliDex?"; break; } } } if (MainService.CheckPendingTrade() == true) { msg = "You are involved in a trade. If you close now, you may lose trade amount. Are you sure you want to exit NebliDex?"; } bool ok = MainService.PromptUser("Confirmation", msg, "Yes", "No"); if (ok == true) { MainService.ExitProgram(); } }); }