public void Signaled() { using (WebJobsShutdownContext shutdownContext = new WebJobsShutdownContext()) using (var watcher = new WebJobsShutdownWatcher()) { var token = watcher.Token; Assert.True(!token.IsCancellationRequested); // Write the file shutdownContext.NotifyShutdown(); // Token should be signaled very soon Assert.True(token.WaitHandle.WaitOne(500)); } }
public void NotSignaledAfterDisposed() { using (WebJobsShutdownContext shutdownContext = new WebJobsShutdownContext()) { CancellationToken token; using (var watcher = new WebJobsShutdownWatcher()) { token = watcher.Token; Assert.True(!token.IsCancellationRequested); } // Write the file shutdownContext.NotifyShutdown(); Assert.True(!token.IsCancellationRequested); } }
public void WebJobsShutdown_WhenUsingTriggeredFunction_TriggersCancellationToken() { using (WebJobsShutdownContext shutdownContext = new WebJobsShutdownContext()) using (JobHost host = new JobHost(_hostConfiguration)) { _invokeInFunction = () => { shutdownContext.NotifyShutdown(); }; PrepareHostForTrigger(host, startHost: true); EvaluateTriggeredCancellation(expectedCancellation: true); } }
public void WebJobsShutdown_WhenUsingHostCall_TriggersCancellationToken() { using (WebJobsShutdownContext shutdownContext = new WebJobsShutdownContext()) using (JobHost host = new JobHost(_hostConfiguration)) { _invokeInFunction = () => { shutdownContext.NotifyShutdown(); }; Task callTask = InvokeNoAutomaticTriggerFunction(host); EvaluateNoAutomaticTriggerCancellation(callTask, expectedCancellation: true); } }