Пример #1
0
        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;
            }
        }
Пример #2
0
        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());
            }
        }
Пример #3
0
        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());
            }
        }
Пример #4
0
        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;
            }
        }
Пример #5
0
 static void OnProcessExit(object sender, EventArgs e)
 {
     CurrentCli?.CancelAll();
 }