public void AsyncBlockUntilCompleteWithException() { InvalidOperationException terminatingException = new InvalidOperationException("Failure succeeded"); AsynchronousTask task = new AsynchronousTask(1, terminatingException); IAsyncResult ar = task.BeginDoTask(null, this); Assert.Throws <InvalidOperationException>(delegate { task.EndDoTask(ar); }); }
public void AsyncBlockUntilComplete() { AsynchronousTask task = new AsynchronousTask(1); IAsyncResult ar = task.BeginDoTask(null, this); Stopwatch timer = Stopwatch.StartNew(); task.EndDoTask(ar); timer.Stop(); Assert.True(ar.IsCompleted); Assert.False(ar.CompletedSynchronously); Assert.True(timer.ElapsedMilliseconds > 500L); }
public void AsyncCallBackNotification() { CallBackHelper callBackRecorder = new CallBackHelper(); AsynchronousTask task = new AsynchronousTask(1); IAsyncResult ar = task.BeginDoTask(callBackRecorder.CallBack, this); Thread.Sleep(2000); Assert.Same(ar, callBackRecorder.Result); Assert.True(ar.IsCompleted); Assert.False(ar.CompletedSynchronously); task.EndDoTask(ar); // should not throw }
public void AsyncCallBackNotificationWithException() { CallBackHelper callBackRecorder = new CallBackHelper(); InvalidOperationException terminatingException = new InvalidOperationException("Failure succeeded"); AsynchronousTask<String> task = new AsynchronousTask<String>(1, terminatingException); IAsyncResult ar = task.BeginDoTask(callBackRecorder.CallBack, this); Thread.Sleep(2000); Assert.Same(ar, callBackRecorder.Result); Assert.True(ar.IsCompleted); Assert.False(ar.CompletedSynchronously); Assert.Throws<InvalidOperationException>(delegate { task.EndDoTask(ar); }); }
public void AsyncCallBackNotificationWithException() { CallBackHelper callBackRecorder = new CallBackHelper(); InvalidOperationException terminatingException = new InvalidOperationException("Failure succeeded"); AsynchronousTask task = new AsynchronousTask(1, terminatingException); IAsyncResult ar = task.BeginDoTask(callBackRecorder.CallBack, this); Thread.Sleep(2000); Assert.Same(ar, callBackRecorder.Result); Assert.True(ar.IsCompleted); Assert.False(ar.CompletedSynchronously); Assert.Throws <InvalidOperationException>(delegate { task.EndDoTask(ar); }); }
public void AsyncBlockUntilComplete() { String expectedResult = "Result we expected"; AsynchronousTask <String> task = new AsynchronousTask <String>(expectedResult, 1); IAsyncResult ar = task.BeginDoTask(null, this); Stopwatch timer = Stopwatch.StartNew(); String actualResult = task.EndDoTask(ar); timer.Stop(); Assert.True(ar.IsCompleted); Assert.False(ar.CompletedSynchronously); Assert.Same(expectedResult, actualResult); Assert.True(timer.ElapsedMilliseconds > 500L); }
public void AsyncCallBackNotification() { CallBackHelper callBackRecorder = new CallBackHelper(); String expectedResult = "Result we expected"; AsynchronousTask<String> task = new AsynchronousTask<String>(expectedResult, 1); IAsyncResult ar = task.BeginDoTask(callBackRecorder.CallBack, this); Thread.Sleep(2000); Assert.Same(ar, callBackRecorder.Result); Assert.True(ar.IsCompleted); Assert.False(ar.CompletedSynchronously); String actualResult = task.EndDoTask(ar); // should not throw Assert.Same(expectedResult, actualResult); }
public void AsyncPollingNotificationWithException() { InvalidOperationException terminatingException = new InvalidOperationException("Failure succeeded"); AsynchronousTask task = new AsynchronousTask(1, terminatingException); IAsyncResult ar = task.BeginDoTask(null, this); while (!ar.IsCompleted) { Thread.Sleep(500); } Assert.True(ar.IsCompleted); Assert.False(ar.CompletedSynchronously); Assert.Throws <InvalidOperationException>(delegate { task.EndDoTask(ar); }); }
public void AsyncCallBackNotification() { CallBackHelper callBackRecorder = new CallBackHelper(); String expectedResult = "Result we expected"; AsynchronousTask <String> task = new AsynchronousTask <String>(expectedResult, 1); IAsyncResult ar = task.BeginDoTask(callBackRecorder.CallBack, this); Thread.Sleep(2000); Assert.Same(ar, callBackRecorder.Result); Assert.True(ar.IsCompleted); Assert.False(ar.CompletedSynchronously); String actualResult = task.EndDoTask(ar); // should not throw Assert.Same(expectedResult, actualResult); }
public void AsyncPollingNotification() { AsynchronousTask task = new AsynchronousTask(1); IAsyncResult ar = task.BeginDoTask(null, this); Int32 count = 0; while (!ar.IsCompleted) { count++; Thread.Sleep(500); } Assert.True(count > 0); Assert.True(ar.IsCompleted); Assert.False(ar.CompletedSynchronously); task.EndDoTask(ar); // should not throw }
public void AsyncPollingNotification() { String expectedResult = "Result we expected"; AsynchronousTask<String> task = new AsynchronousTask<String>(expectedResult, 1); IAsyncResult ar = task.BeginDoTask(null, this); Int32 count = 0; while (!ar.IsCompleted) { count++; Thread.Sleep(500); } Assert.True(count > 0); Assert.True(ar.IsCompleted); Assert.False(ar.CompletedSynchronously); String actualResult = task.EndDoTask(ar); // should not throw Assert.Same(expectedResult, actualResult); }
public void AsyncPollingNotification() { String expectedResult = "Result we expected"; AsynchronousTask <String> task = new AsynchronousTask <String>(expectedResult, 1); IAsyncResult ar = task.BeginDoTask(null, this); Int32 count = 0; while (!ar.IsCompleted) { count++; Thread.Sleep(500); } Assert.True(count > 0); Assert.True(ar.IsCompleted); Assert.False(ar.CompletedSynchronously); String actualResult = task.EndDoTask(ar); // should not throw Assert.Same(expectedResult, actualResult); }
public void AsyncPollingNotificationWithException() { InvalidOperationException terminatingException = new InvalidOperationException("Failure succeeded"); AsynchronousTask<String> task = new AsynchronousTask<String>(1, terminatingException); IAsyncResult ar = task.BeginDoTask(null, this); while (!ar.IsCompleted) { Thread.Sleep(500); } Assert.True(ar.IsCompleted); Assert.False(ar.CompletedSynchronously); Assert.Throws<InvalidOperationException>(delegate { task.EndDoTask(ar); }); }
public void AsyncBlockUntilCompleteWithException() { InvalidOperationException terminatingException = new InvalidOperationException("Failure succeeded"); AsynchronousTask<String> task = new AsynchronousTask<String>(1, terminatingException); IAsyncResult ar = task.BeginDoTask(null, this); Assert.Throws<InvalidOperationException>(delegate { task.EndDoTask(ar); }); }
public void AsyncBlockUntilComplete() { String expectedResult = "Result we expected"; AsynchronousTask<String> task = new AsynchronousTask<String>(expectedResult, 1); IAsyncResult ar = task.BeginDoTask(null, this); Stopwatch timer = Stopwatch.StartNew(); String actualResult = task.EndDoTask(ar); timer.Stop(); Assert.True(ar.IsCompleted); Assert.False(ar.CompletedSynchronously); Assert.Same(expectedResult, actualResult); Assert.True(timer.ElapsedMilliseconds > 500L); }