銷售: 1-800-867-1380

RoleEnvironment.StatusCheck 事件

Occurs at a regular interval to indicate the status of a role instance.

命名空間: Microsoft.WindowsAzure.ServiceRuntime
組件: Microsoft.WindowsAzure.ServiceRuntime (在 microsoft.windowsazure.serviceruntime.dll 中)

'用途
Dim handler As EventHandler(Of RoleInstanceStatusCheckEventArgs)

AddHandler RoleEnvironment.StatusCheck, handler

public static event EventHandler<RoleInstanceStatusCheckEventArgs> StatusCheck
/** @event */
public static void add_StatusCheck (EventHandler<RoleInstanceStatusCheckEventArgs> value)

/** @event */
public static void remove_StatusCheck (EventHandler<RoleInstanceStatusCheckEventArgs> value)

You can use the StatusCheck event to change the status of the role instance. A role instance may indicate that it is in one of two states: Ready or Busy. If the state of a role instance is Ready, it is prepared to receive requests from the load balancer. If the state of the instance is Busy, it will not receive requests from the load balancer. By calling the SetBusy method of RoleInstanceStatusCheckEventArgs, you can temporarily set the status of the role instance to Busy, which removes the role instance from the load balancer.

The following code example shows how to set the status of the role instance to Busy:


public override bool OnStart()
{
   RoleEnvironment.StatusCheck += RoleEnvironmentStatusCheck;

   return base.OnStart();
}

// Use the busy object to indicate that the status of the role instance must be Busy
private volatile bool busy = true;
    
private void RoleEnvironmentStatusCheck(object sender, RoleInstanceStatusCheckEventArgs e)
{
   If (this.busy)
   {
      // Sets the status of the role instance to Busy for a short interval.
      // If you want the role instance to remain busy, add code to 
      // continue to call the SetBusy method
      e.SetBusy();
   }
}

開發平台

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

目標平台

本文對您有任何幫助嗎?
(剩餘 1500 個字元)
感謝您提供意見

社群新增項目

顯示:
© 2014 Microsoft