Exportar (0) Imprimir
Expandir Tudo

Método RoleEntryPoint.OnStop

[Este tópico é uma documentação de pré-lançamento e está sujeito a alterações em versões futuras. Os tópicos em branco são incluídos como espaços reservados.]

Runs code when a role instance is to be stopped.

Namespace: Microsoft.WindowsAzure.ServiceRuntime
Assembly: Microsoft.WindowsAzure.ServiceRuntime (em microsoft.windowsazure.serviceruntime.dll)

'Uso
Dim instance As RoleEntryPoint

instance.OnStop

public:
virtual void OnStop ()
public void OnStop ()
public function 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.
   }
}
noteObservação:
Code running in the OnStop method has a limited time 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.

A web role can include initialization code in the ASP.NET Application_End method instead of the OnStop method. The Application_Start 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.


Todos os membros estáticos públicos (Compartilhados no Visual Basic) desse tipo são thread-safe. Quaisquer membros de instância não têm garantia de ser thread-safe.

Plataformas de desenvolvimento

Windows XP Professional com Service Pack 2 (SP2)

Plataformas de destino

Contribuições da comunidade

Mostrar:
© 2014 Microsoft