이 항목은 아직 평가되지 않았습니다.- 이 항목 평가

RoleEntryPoint.OnStart 메서드

Runs code that initializes a role instance.

네임스페이스: Microsoft.WindowsAzure.ServiceRuntime
어셈블리: Microsoft.WindowsAzure.ServiceRuntime(microsoft.windowsazure.serviceruntime.dll)
‘사용 방법
Dim instance As RoleEntryPoint
Dim returnValue As Boolean

returnValue = instance.OnStart
public virtual bool OnStart ()
public boolean OnStart ()
public function OnStart () : boolean

반환 값

true if initialization succeeds; otherwise, false. The default return value is true.

Override the OnStart method to run initialization code for your role. The following code example shows how to override the OnStart method:


public class WorkerRole : RoleEntryPoint
{
   public override bool OnStart()
   { 
      try
      {
         // Add initialization code here
      } 
      catch (Exception e)
      {
         Trace.WriteLine("Exception during OnStart: " + e.ToString());
         // Take other action as needed.
      }
 
      return base.OnStart();
   }
}

Before the OnStart method returns, the status of the role instance is set to Busy and the instance is not available through the load balancer.

If the OnStart method returns false, the role instance is immediately stopped. If the method returns true, Windows Azure starts the role by calling the Run method. In general, you should avoid returning false from the OnStart method.

A web role can include initialization code in the ASP.NET Application_Start method instead of the OnStart method. The Application_Start method is called after the OnStart method. For more information about the Application_Start 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.


이 형식의 모든 public static(Shared, Visual Basic의 경우) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

개발 플랫폼

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Server 2008 및 Windows 2000

대상 플랫폼

이 정보가 도움이 되었습니까?
(1500자 남음)

커뮤니티 추가 항목

© 2013 Microsoft. All rights reserved.
facebook page visit twitter rss feed newsletter