static void CancelKeyPress(object sender, ConsoleCancelEventArgs _args) { if (_args.SpecialKey == ConsoleSpecialKey.ControlC) { Console.WriteLine("\nCancelling..."); _cancellationToken.Cancel(); } }
private void ThreadCaller(Action method) { try { method?.Invoke(); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); _cancellationToken.Cancel(); _isSuccess = false; } }