SALES: 1-800-867-1380

RoleEnvironment.StatusCheck Event

Updated: December 6, 2013

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

Namespace: Microsoft.WindowsAzure.ServiceRuntime
Assembly: Microsoft.WindowsAzure.ServiceRuntime (in Microsoft.WindowsAzure.ServiceRuntime.dll)

public static event EventHandler<RoleInstanceStatusCheckEventArgs> StatusCheck

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

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

Target Platforms

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft