导出 (0) 打印
全部展开
此主题尚未评级 - 评价此主题

RoleEntryPoint.OnStop 方法

Runs code when a role instance is to be stopped.

命名空间: Microsoft.WindowsAzure.ServiceRuntime
程序集: Microsoft.WindowsAzure.ServiceRuntime(在 microsoft.windowsazure.serviceruntime.dll 中)
用法
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.
   }
}
note说明
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.


此类型的任何公共静态(在 Visual Basic 中为 Shared)成员都是线程安全的。但不保证所有实例成员都是线程安全的。

开发平台

Windows XP Home Edition, Windows XP Professional, Windows Server 2003、Windows Server 2008 和 Windows 2000

目标平台

本文是否对您有所帮助?
(1500 个剩余字符)
感谢您的反馈

社区附加资源

显示:
© 2014 Microsoft. 版权所有。