Esporta (0) Stampa
Espandi tutto

Metodo RoleEntryPoint.OnStart

Runs code that initializes a role instance.

Spazio dei nomi: Microsoft.WindowsAzure.ServiceRuntime
Assembly: Microsoft.WindowsAzure.ServiceRuntime (in 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

Valore restituito

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()
         // 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.

Tutti i membri statici pubblici (Shared in Visual Basic) di questo tipo sono thread-safe. I membri di istanza non sono garantiti come thread-safe.

Piattaforme di sviluppo

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

Piattaforme di destinazione

Aggiunte alla community

© 2014 Microsoft