• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# RoleEnvironmentChangingEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中RoleEnvironmentChangingEventArgs的典型用法代码示例。如果您正苦于以下问题:C# RoleEnvironmentChangingEventArgs类的具体用法?C# RoleEnvironmentChangingEventArgs怎么用?C# RoleEnvironmentChangingEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RoleEnvironmentChangingEventArgs类属于命名空间,在下文中一共展示了RoleEnvironmentChangingEventArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RoleEnvironmentChanging

 /// <summary>
 /// Event handler called when an environment change is to be applied to the role.
 /// Determines whether or not the role instance must be recycled.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The list of changed environment values.</param>
 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // If Azure should recycle the role, e.Cancel should be set to true.
     // If the changes are ones we can handle without a recycle, we set it to false.
     e.Cancel = this.RecycleConfiguration(e.Changes);
     Trace.WriteLine("WebRole environment change - role instance recycling: " + e.Cancel.ToString());
 }
开发者ID:wpdiary,项目名称:PolyGlotPersistence,代码行数:13,代码来源:WebRole.cs


示例2: RoleEnvironmentChanging

 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // If a configuration setting is changing
     if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
         // set e.Cancel to true to restart this role instance
         e.Cancel = true;
 }
开发者ID:eakova,项目名称:resizer,代码行数:7,代码来源:Webrole.cs


示例3: RoleEnvironmentChanging

 private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
     {
         e.Cancel = true;
     }
 }
开发者ID:Adron,项目名称:windowsazurefordevelopers,代码行数:7,代码来源:WorkerRole.cs


示例4: RoleEnvironmentChanging

        private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            if (!e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange)) return;

            Trace.WriteLine("Working", "Environment Change: " + e.Changes.ToList());
            e.Cancel = true;
        }
开发者ID:Adron,项目名称:windowsazurefordevelopers,代码行数:7,代码来源:WorkerRole.cs


示例5: RoleEnvironmentChanging

        //Event Handler
        public void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            var changes = from ch in e.Changes.OfType<RoleEnvironmentTopologyChange>()
                          select ch;
            if (changes.Any())
            {
                const string semaphoreName = "SemaphoreShutDown";
                Semaphore sem = null;

                // Attempt to open the named semaphore.
                try
                {
                    sem = Semaphore.OpenExisting(semaphoreName);
                }
                catch (WaitHandleCannotBeOpenedException)
                {
                    return;
                }
                sem.Release(1);

                //Note this may be superfulous, as this event may be running on a non-blocking thread.  To be investigated.
                //If a blocking thread, this gives some time for IIS to complete its shutdown, based on the semaphore release
                //above.  
                Thread.Sleep(20000);
            }
        }
开发者ID:vactorwu,项目名称:catch23-project,代码行数:27,代码来源:WebRole.cs


示例6: RoleEnvironmentChanging

 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     //Are any of the environment changes a configuration setting change? If so, cancel the event and restart the role
     if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
     {
         e.Cancel = true;
     }
 }
开发者ID:Adron,项目名称:windowsazurefordevelopers,代码行数:8,代码来源:WebRole.cs


示例7: RoleEnvironmentChanging

 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     e.Cancel = false; // don't restart for configuration changes
     /*if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
     {
         e.Cancel = true;
     }*/
 }
开发者ID:smarx,项目名称:NetflixPivot,代码行数:8,代码来源:WebRole.cs


示例8: RoleEnvironment_Changing

 static void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e)
 {
     if (e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>().Count() > 0)
     {
         // Cancel the changing event to force role instance restart
         //e.Cancel = true;
     }
 }
开发者ID:CDLUC3,项目名称:dataup2,代码行数:8,代码来源:WebRole.cs


示例9: RoleEnvironmentChanging

 private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     // for any configuration setting change except EnableTableStorageTraceListener
     if (e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>().Any(change => change.ConfigurationSettingName != "EnableTableStorageTraceListener"))
     {
         // Set e.Cancel to true to restart this role instance
         e.Cancel = true;
     }
 }
开发者ID:st4l,项目名称:HOL-DebuggingCloudServices-VS2012,代码行数:9,代码来源:WebRole.cs


示例10: RoleEnvironmentChanging

        static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            var i = 1;
            foreach (var c in e.Changes)
                Trace.WriteLine(string.Format("RoleEnvironmentChanging: #{0} Type={1} Change={2}", i++, c.GetType().FullName, c));

            if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
                e.Cancel = true;
        }
开发者ID:mekoda,项目名称:DesignPatterns,代码行数:9,代码来源:WorkerRole.cs


示例11: HandleRoleEnvironmentChanging

 private void HandleRoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     foreach(var c in e.Changes.OfType<RoleEnvironmentTopologyChange>())
     {
         if (c.RoleName.Equals(AzureConstants.StoreWorkerRoleName))
         {
             Trace.TraceInformation("BrightstarCluster: Received RoleEnvironmentTopologyChange event. Updating store worker client list");
             UpdateClientList();
         }
     }
 }
开发者ID:Garwin4j,项目名称:BrightstarDB,代码行数:11,代码来源:BrightstarCluster.cs


示例12: OnRoleEnvironmentChanging

        static void OnRoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            // we restart all workers if the configuration changed (e.g. the storage account)
            // for now.

            // We do not request a recycle if only the topology changed,
            // e.g. if some instances have been removed or added.
            var configChanges = e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>();

            if(configChanges.Any())
            {
                RoleEnvironment.RequestRecycle();
            }
        }
开发者ID:kmaclean,项目名称:lokad-cloud,代码行数:14,代码来源:ServiceFabricHost.cs


示例13: RoleEnvironmentChanging

        private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            int i = 1;
            foreach (var c in e.Changes)
            {
                Trace.WriteLine(string.Format("RoleEnvironmentChanging: #{0} Type={1} Change={2}", i++, c.GetType().FullName, c));
            }

            // If a configuration setting is changing);
            if (e.Changes.Any((RoleEnvironmentChange change) => change is RoleEnvironmentConfigurationSettingChange))
            {
                // Set e.Cancel to true to restart this role instance
                e.Cancel = true;
            }
        }
开发者ID:Rejendo,项目名称:orleans,代码行数:15,代码来源:WorkerRole.cs


示例14: RoleEnvironment_Changing

        void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e)
        {
            Trace.TraceInformation("Change notification");

            if (e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
                .Any(c => !string.Equals(c.ConfigurationSettingName, MvcApplication.AzureLoggingVerbositySettingName, StringComparison.Ordinal)))
            {
                Trace.TraceInformation("Cancelling instance");
                e.Cancel = true;
            }
            else
            {
                Trace.TraceInformation("Handling change without recycle");
            }
        }
开发者ID:husains,项目名称:semantic-logging,代码行数:15,代码来源:WebRole.cs


示例15: OnChanging

 private void OnChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     foreach (var change in e.Changes)
     {
         var configChange = change as RoleEnvironmentConfigurationSettingChange;
         if (configChange != null)
         {
             if (configChange.ConfigurationSettingName == "DatabaseConnectionString")
             {
                 // Our database connectionstring changed.
                 // Maybe we need to restart the instance to make sure our cached objects no longer use the previous value.
                 e.Cancel = true;
             }
         }
     }
 }
开发者ID:justazure,项目名称:JustAzure.CloudServices,代码行数:16,代码来源:WebRole.cs


示例16: RoleEnvironmentOnChanging

        private void RoleEnvironmentOnChanging(object sender, RoleEnvironmentChangingEventArgs roleEnvironmentChangingEventArgs)
        {
            // In order to handle changing configuration
            // this can be avoided if the config is not "singleton" but it is recreated via this event
            // https://msdn.microsoft.com/en-us/library/azure/gg432963.aspx
            // https://alexandrebrisebois.wordpress.com/2013/09/29/handling-cloud-service-role-configuration-changes-in-windows-azure/

            var configurationChanges = roleEnvironmentChangingEventArgs.Changes
                                    .OfType<RoleEnvironmentConfigurationSettingChange>()
                                    .ToList();

            if (!configurationChanges.Any())
            {
                return;
            }

            // TODO for specific settings which are uesd to instantiate any cached objects
            //if(configurationChanges.Any(c => c.ConfigurationSettingName == "StorageAccount"))
            roleEnvironmentChangingEventArgs.Cancel = true;
        }
开发者ID:ognyandim,项目名称:AzureStrongConfig,代码行数:20,代码来源:WebRole.cs


示例17: RoleEnvironment_Changing

        private void RoleEnvironment_Changing(object sender, RoleEnvironmentChangingEventArgs e)
        {
            var changedSettings = e.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
                                            .Select(c => c.ConfigurationSettingName).ToList();

            Trace.TraceInformation("Configuration Changing notification. Settings being changed: "
                + string.Join(", ", changedSettings));

            if (changedSettings
                .Any(settingName => !string.Equals(settingName, CustomSettingName, StringComparison.Ordinal)))
            {
                Trace.TraceInformation("Cancelling dynamic configuration change (restarting).");

                // Setting this to true will restart the role gracefully. If Cancel is not set to true,
                // and the change is not handled by the application, then the application will not use
                // the new value until it is restarted (either manually or for some other reason).
                e.Cancel = true;
            }
            else
            {
                Trace.TraceInformation("Handling configuration change without restarting.");
            }
        }
开发者ID:mspnp,项目名称:cloud-design-patterns,代码行数:23,代码来源:WebRole.cs


示例18: RoleEnvironmentChanging

        private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            Boolean recycle = false;
            foreach (RoleEnvironmentChange change in e.Changes)
            {
                RoleEnvironmentTopologyChange topologyChange = change as RoleEnvironmentTopologyChange;
                if (topologyChange != null)
                {
                    String roleName = topologyChange.RoleName;
                    ReadOnlyCollection<RoleInstance> oldInstances = RoleEnvironment.Roles[roleName].Instances;
                }
                RoleEnvironmentConfigurationSettingChange settingChange = change as RoleEnvironmentConfigurationSettingChange;
                if (settingChange != null)
                {
                    String settingName = settingChange.ConfigurationSettingName;
                    String oldValue = RoleEnvironment.GetConfigurationSettingValue(settingName);
                    recycle |= settingName == "SettingRequiringRecycle";
                }
            }

            // Recycle when e.Cancel = true;
            e.Cancel = recycle;
        }
开发者ID:yoshiao,项目名称:Azure_Parallel_Samples,代码行数:23,代码来源:EnvironmentChangeExample.cs


示例19: OnRoleEnvironmentChanging

 /// <summary>
 /// Force restart of the instance.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void OnRoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
 {
     if (e.Changes.Any(o => o is RoleEnvironmentChange))
         e.Cancel = true;
 }
开发者ID:Wdovin,项目名称:vc-community,代码行数:10,代码来源:WebRole.cs


示例20: RoleEnvironmentChanging

        private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
        {
            Trace.TraceInformation("RoleEnvironmentChanging Event Fired");

            var changes = e.Changes
                           .OfType<RoleEnvironmentConfigurationSettingChange>()
                           .ToList();

            if (!changes.Any())
            {
                return;
            }

            e.Cancel = true; // Instruct server to reboot on change (if not canceled below)

            // TODO: Implement (for now just repboot server)
            //// Service Bus Connection Strings Updated
            //if (changes.Any(c => c.ConfigurationSettingName == ServiceBus.FrontendServiceBusConnectionStringName))
            //{
            //    e.Cancel = false; // Cancel reboot of server
            //}
            //if (changes.Any(c => c.ConfigurationSettingName == ServiceBus.WorkerServiceBusConnectionStringName))
            //{
            //    e.Cancel = false; // Cancel reboot of server
            //}
        }
开发者ID:baiyunping333,项目名称:BlazeDSP,代码行数:26,代码来源:WorkerRole.cs



注:本文中的RoleEnvironmentChangingEventArgs类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RoleManager类代码示例发布时间:2022-05-24
下一篇:
C# Role类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap