Exemplo n.º 1
0
        public async Task TestCommandCancellation()
        {
            var taskCommand = new TaskCommand(TestExecute);

            Assert.IsFalse(taskCommand.IsExecuting);
            Assert.IsFalse(taskCommand.IsCancellationRequested);

            taskCommand.Execute();

            Assert.IsTrue(taskCommand.IsExecuting);
            await Task.Delay(TimeSpan.FromSeconds(1));

            taskCommand.Cancel();

            await Task.Delay(TimeSpan.FromSeconds(1));
            Assert.IsFalse(taskCommand.IsExecuting);
            Assert.IsFalse(taskCommand.IsCancellationRequested);
        }
Exemplo n.º 2
0
        public async Task TestCommandCancellation()
        {
            var taskCommand = new TaskCommand(TestExecute);

            Assert.IsFalse(taskCommand.IsExecuting);
            Assert.IsFalse(taskCommand.IsCancellationRequested);

            taskCommand.Execute();

            Assert.IsTrue(taskCommand.IsExecuting);
            await Task.Delay(TimeSpan.FromSeconds(1));

            taskCommand.Cancel();

            await Task.Delay(TimeSpan.FromSeconds(1));

            Assert.IsFalse(taskCommand.IsExecuting);
            Assert.IsFalse(taskCommand.IsCancellationRequested);
        }
Exemplo n.º 3
0
        public void TestCommandCancellation()
        {
            var taskCommand = new TaskCommand(TestExecuteAsync);

            Assert.IsFalse(taskCommand.IsExecuting);
            Assert.IsFalse(taskCommand.IsCancellationRequested);

            taskCommand.Execute();

            Assert.IsTrue(taskCommand.IsExecuting);

            ThreadHelper.Sleep(1000);

            taskCommand.Cancel();

            ThreadHelper.Sleep(1000);

            Assert.IsFalse(taskCommand.IsExecuting);
            Assert.IsFalse(taskCommand.IsCancellationRequested);
        }
Exemplo n.º 4
0
        public void TestCommandCancellation()
        {
            var taskCommand = new TaskCommand(TestExecuteAsync);

            Assert.IsFalse(taskCommand.IsExecuting);
            Assert.IsFalse(taskCommand.IsCancellationRequested);

            taskCommand.Execute();

            Assert.IsTrue(taskCommand.IsExecuting);

            ThreadHelper.Sleep(1000);

            taskCommand.Cancel();

            ThreadHelper.Sleep(1000);

            Assert.IsFalse(taskCommand.IsExecuting);
            Assert.IsFalse(taskCommand.IsCancellationRequested);
        }