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

RoleEntryPoint.Run-Methode

Runs code that is intended to be run for the life of the role instance.

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

instance.Run
public virtual void Run ()
public void Run ()
public function Run ()

The Run is considered the Main method for your application. Overriding the Run method is not required; the default implementation never returns. If you do override the Run method, your code should block indefinitely. If the Run method returns, the role is automatically recycled by raising the Stopping event and calling the OnStop method so that your shutdown sequences may be executed before the role is taken offline.

Override the Run method to run code for the life of the role instance. The following code example shows how to override the Run method:


public override void Run()
{
   try
   {
      Trace.WriteLine("WorkerRole entrypoint called", "Information");
      while (true)
      {
         Thread.Sleep(10000);
         Trace.WriteLine("Working", "Information");
      }
      // Add code here that runs in the role instance
   }
   catch (Exception e)
   {
      Trace.WriteLine("Exception during Run: " + e.ToString());
      // Take other action as needed.
   }
}

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.