Eksporter (0) Skriv ut
Vis alt
EN
Dette innholdet er ikke tilgjengelig på ditt språk, men her er den engelske versjonen.
5 av 11 vurderte dette som nyttig - Vurder dette emnet

RoleEntryPoint.OnStop Method

Runs code when a role instance is to be stopped.

Namespace: Microsoft.WindowsAzure.ServiceRuntime
Assembly: Microsoft.WindowsAzure.ServiceRuntime (in Microsoft.WindowsAzure.ServiceRuntime.dll)
'Bruk

public:
virtual void OnStop ()

Override the OnStop method to run code when the role instance is stopped. The following code example shows how to override the OnStop method:


public override void OnStop()
{ 
   try
   {
      // Add code here that runs when the role instance is to be stopped
   } 
   catch (Exception e)
   {
      Trace.WriteLine("Exception during OnStop: " + e.ToString());
      // Take other action as needed.
   }
}
noteNote
Code running in the OnStop method has 5 minutes to finish when it is called for reasons other than a user-initiated shutdown. After this time elapses, the process is terminated, so you must make sure that code in the OnStop method can run quickly or tolerates not running to completion.

Once the OnStop method has finished executing, the role will be stopped. If other code requires time to exit gracefully you should keep the OnStop thread busy until execution is complete.

A web role can include termination code in the ASP.NET Application_End method instead of the OnStop method. The Application_End method is called before the Stopping event is raised or the OnStop method is called. For more information about the Application_End method, see ASP.NET Application Life Cycle Overview for IIS 5.0 and 6.0.

For more information about life cycle management, see Overview of Building an Application that Runs in a Hosted Service.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Vista, Windows 7 and Windows Server 2008

Target Platforms

Vurderte du dette som nyttig?
(1500 tegn igjen)
Takk for tilbakemeldingen

Fellesskapsinnhold

Legg til
Vis:
© 2014 Microsoft. Med enerett.