Share via


RoleEnvironmentChangingEventArgs Class

 

Represents the arguments for the Changing event, which occurs before a configuration change is applied to a role instance.

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

Inheritance Hierarchy

System.Object
  System.EventArgs
    System.ComponentModel.CancelEventArgs
      Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironmentChangingEventArgs

Syntax

public class RoleEnvironmentChangingEventArgs : CancelEventArgs
public ref class RoleEnvironmentChangingEventArgs : CancelEventArgs
type RoleEnvironmentChangingEventArgs = 
    class
        inherit CancelEventArgs
    end
Public Class RoleEnvironmentChangingEventArgs
    Inherits CancelEventArgs

Properties

Name Description
System_CAPS_pubproperty Cancel

(Inherited from CancelEventArgs.)

System_CAPS_pubproperty Changes

Gets a collection of the configuration changes that are ready to be applied to the role instance.

Methods

Name Description
System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_protmethod Finalize()

(Inherited from Object.)

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_protmethod MemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethod ToString()

(Inherited from Object.)

Remarks

The Changing event and the Changed event are used together to identify and manage configuration changes to the service model. By using the Changing event, an instance can respond to a configuration change in one of the following ways:

  • Accept the configuration change while it is running, without going offline.

  • Set the Cancel property of RoleEnvironmentChangingEventArgs to true to take the instance offline, apply the configuration change, and then bring the instance back online.

By using the Cancel property, you can ensure that the instance proceeds through an orderly shutdown sequence and is taken offline before the configuration change is applied. During the shutdown process, Windows Azure raises the Stopping event, and then runs any code in the OnStop method.

The following code example shows how to apply the configuration changes after the role instances are restarted:

public override bool OnStart()
{
   RoleEnvironment.Changing += RoleEnvironmentChanging;

   return base.OnStart();
}   

private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e) 
{
   // Implements the changes after restarting the role instance
   if ((e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))) 
   {
      e.Cancel = true;
   }
}

The Changing event occurs after the change has been submitted to Windows Azure but before the changes have been applied to each running role instance.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

RoleEnvironment
RoleEnvironmentConfigurationSettingChange
Microsoft.WindowsAzure.ServiceRuntime Namespace

Return to top