private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { if (_cliCompose != null) { _cliCompose.CancelAll(); _cliCompose.Dispose(); } if (_cliDocker != null) { _cliDocker.CancelAll(); _cliDocker.Dispose(); } } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. //if (Directory.Exists(_executionPath)) Directory.Delete(_executionPath, true); disposedValue = true; } }
public void CancelAll_AfterExecuteAsync_Sleep_Test() { using (var cli = new Cli(_sleepBat)) { // Kill after some time Task.Delay(TimeSpan.FromSeconds(1)).ContinueWith(_ => cli.CancelAll()); // Execute Assert.ThrowsAsync <TaskCanceledException>(() => cli.ExecuteAsync()); } }
public void CancelAll_AfterExecute_Sleep_Test() { using (var cli = new Cli(_sleepBat)) { // Kill after some time Task.Run(async() => { await Task.Delay(TimeSpan.FromSeconds(1)); cli.CancelAll(); }).Forget(); // Execute Assert.Throws <OperationCanceledException>(() => cli.Execute()); } }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { if (_cliDocker != null) { _cliDocker.CancelAll(); _cliDocker.Dispose(); } } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. disposedValue = true; } }
static void OnProcessExit(object sender, EventArgs e) { CurrentCli?.CancelAll(); }