Hade du nytta av den här sidan?
Din feedback om det här innehållet är viktig. Berätta vad du tycker.
Ytterligare feedback?
1500 tecken kvar
Exportera (0) Skriv ut
Visa allt
EN
Det här innehållet finns inte tillgängligt på ditt språk men här finns den engelska versionen,

Use the RoleEnvironment.Changed Event

Updated: October 24, 2014

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.

  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

Visa:
© 2015 Microsoft