(0) exportieren Drucken
Alle erweitern
Dieser Artikel wurde noch nicht bewertet - Dieses Thema bewerten.

RoleEntryPoint.OnStart-Methode

Runs code that initializes a role instance.

Namespace: Microsoft.WindowsAzure.ServiceRuntime
Assembly: Microsoft.WindowsAzure.ServiceRuntime (in microsoft.windowsazure.serviceruntime.dll)
'Usage
Dim instance As RoleEntryPoint
Dim returnValue As Boolean

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

Rückgabewert

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.


Alle öffentlichen statischen (freigegebenen in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Entwicklungsplattformen

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

Zielplattformen

Fanden Sie dies hilfreich?
(1500 verbleibende Zeichen)
Vielen Dank für Ihr Feedback.

Community-Beiträge

Anzeigen:
© 2014 Microsoft. Alle Rechte vorbehalten.