Exporteren (0) Afdrukken
Alles uitvouwen
EN
Deze inhoud is niet beschikbaar in uw taal, maar wel in het Engels.

Use the RoleEnvironment.Changed Event

Updated: November 13, 2013

The Changed event occurs after a configuration change is applied to a role instance.

The RoleEnvironmentChangingEventArgs class provides a Changes property that returns the collection of the configuration changes that were applied to the instance. The Changed event is raised after the changes have been applied. The new values for the configuration settings can be retrieved from the RoleEnvironment.GetConfigurationSettingValue method, while the old values are no longer available.

To define the event handler

  1. Open the source file for the role.

  2. Ensure that the project references the Microsoft.WindowsAzure.ServiceRuntime.dll file and that the following using statement is added to the file:

    using Microsoft.WindowsAzure.ServiceRuntime;
    
  3. Add the following code to specify the event handler:

         
    RoleEnvironment.Changed += (sender, args) =>
    {
       if (args.Changes.Any(chg => chg is RoleEnvironmentTopologyChange)) 
       {
          // Perform an action, for example, you can initialize a client, 
          // or you can recycle the role
       }
    };
    
  4. Save the file.

See Also

Weergeven:
© 2014 Microsoft