public async Task Run() { PrintAppInfo(); Console.CancelKeyPress += (s, e) => { e.Cancel = true; _cancellation.Cancel(); }; _logger.Info("Read stable device info..."); StableDeviceInfo stableDeviceInfo = await _stableDeviceCollector.Read(); _logger.Info(_jsonSerializer.SerializeWithFormatting(stableDeviceInfo)); _logger.Info("Read volatile device info..."); VolatileDeviceInfo volatileDeviceInfo = await _volatileDeviceCollector.Read(); _logger.Info(_jsonSerializer.SerializeWithFormatting(volatileDeviceInfo)); _logger.Info("Send stable device info ..."); await _serverConnector.Send(stableDeviceInfo); _logger.Info("Send volatile device info ..."); await _serverConnector.Send(volatileDeviceInfo); }
static async Task <int> Main(string[] args) { try { var dataDirRoot = SelectDataDirRoot(); Configure(dataDirRoot); CreateLogger(); _cancellation = App.ServiceProvider.GetService <ICancellation>(); Console.CancelKeyPress += (s, e) => { e.Cancel = true; _cancellation.Cancel(); }; App.IsOnboardingRequired = await _cancellation.PrepareLaunch(dataDirRoot); App.ShowUI(); while (!_cancellation.Token.IsCancellationRequested) { _logger.LogInformation("Please press 'C' to go back to the chat application, 'Ctrl-C' to quit."); var key = Console.ReadKey(true); if (key.KeyChar == 'c' || key.KeyChar == 'C') { App.ShowUI(); } } } catch (Exception e) { Console.WriteLine($"There was an error running the program: {e}"); return(1); } return(0); }
public JsonResult Cancel(CancellationRequest request) { return(Json(canceller.Cancel(request))); }
public override void Abort() { _cancellation.Cancel(); }