Redigeeri

Jagamisviis:


HostingEnvironment.StopListening Event

Definition

[Supported in the .NET Framework 4.5.1 only]

Occurs when the worker process or application pool associated with this host has stopped listening for new requests and will eventually shut down.

public:
 static event EventHandler ^ StopListening;
public static event EventHandler StopListening;
member this.StopListening : EventHandler 
Public Shared Custom Event StopListening As EventHandler 
Public Shared Event StopListening As EventHandler 

Event Type

Remarks

When an application pool and its associated worker processes are being shut down by IIS, for example when an application pool has reached a scheduled recycle interval, IIS notifies the ASP.NET runtime that the application is shutting down and the worker process for the application pool stops listening for new requests. Applications that use long-running requests, for example SignalR applications, can listen for the StopListening event and gracefully shut down their long-running operations when IIS has initiated the shutdown of an application pool and its associated worker processes.

Warning

There are several design considerations that a developer must consider when implementing the StopListening event:

  1. The StopListening event is only available for applications that are configured to use the IIS integrated pipeline.
  2. Developers must not throw errors from their StopListening implementations; throwing errors will have unpredictable results.
  3. Due to the concurrent nature of operations within ASP.NET, there is no guarantee that ASP.NET will call a StopListening event once it has been implemented by a developer.
  4. The StopListening event can execute concurrently with other IRegisteredObject notifications.
  5. Developers need to be aware that ASP.NET may shut down the application domain while their StopListening event is executing and design their implementations to handle that possibility.
  6. StopListening event handlers must not block; blocking implementations will result in deadlocks, and IIS will terminate the worker process when the rapid fail protection interval is reached.

Applies to