Gets a CancellationToken object that is tripped when the client disconnects.
Assembly: System.Web (in System.Web.dll)
This API is thread-safe. However, there are some restrictions on how the cancellation token should be used. Using it incorrectly can lead to race conditions, deadlocks, or other unexpected behavior. Keep in mind the following guidelines:
Ensure that you don't call into this API outside the bounds of a single request, because ASP.NET will dispose of the cancellation token at the end of the request. There is no guarantee that the token will ever transition to a canceled state before it is disposed. For example, if the request finishes without the client having disconnected, the token will be disposed without having first been canceled.
Do not wait on the CancellationToken.WaitHandle, as this defeats the purpose of an asynchronous notification and can cause deadlocks.
Do not use the HttpContext object or other non-thread-safe ASP.NET intrinsic objects from within the callback provided to the CancellationToken.Register method. The callback may be running concurrently with other ASP.NET or application code.
Keep the callback methods short-running and non-blocking.
Make every effort to avoid throwing exceptions from within the callback methods.
This property is only applicable to Internet Information Service (IIS) 7.5 in integrated mode. If you invoke it without the right IIS version or pipeline mode, a PlatformNotSupportedException is thrown. To determine the IIS version, use IISVersion. To determine the pipeline mode, use UsingIntegratedPipeline.