本文整理汇总了C#中RoleEnvironmentChangingEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# RoleEnvironmentChangingEventArgs类的具体用法?C# RoleEnvironmentChangingEventArgs怎么用?C# RoleEnvironmentChangingEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RoleEnvironmentChangingEventArgs类属于命名空间,在下文中一共展示了RoleEnvironmentChangingEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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;
}
示例3: RoleEnvironmentChanging
private static void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
{
if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
{
e.Cancel = true;
}
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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;
}*/
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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();
}
}
}
示例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();
}
}
示例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;
}
}
示例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");
}
}
示例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;
}
}
}
}