Editar

Compartir a través de


HttpResponse.ClientDisconnectedToken Property

Definition

Gets a CancellationToken object that is tripped when the client disconnects.

public:
 property System::Threading::CancellationToken ClientDisconnectedToken { System::Threading::CancellationToken get(); };
public System.Threading.CancellationToken ClientDisconnectedToken { get; }
member this.ClientDisconnectedToken : System.Threading.CancellationToken
Public ReadOnly Property ClientDisconnectedToken As CancellationToken

Property Value

The cancellation token.

Remarks

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 call the CancellationToken.Register overloads which invoke the callback on the original SynchronizationContext object.

  • 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 supported in Internet Information Service (IIS) 7.5 or higher 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.

Applies to