internal void InitializeChannelCacheEnabledSetting(SendMessageChannelCache channelCacheExtension) { Fx.Assert(channelCacheExtension != null, "channelCacheExtension cannot be null!"); ChannelCacheSettings factorySettings = channelCacheExtension.FactorySettings; Fx.Assert(factorySettings != null, "FactorySettings cannot be null!"); bool enabled; if (factorySettings.IdleTimeout == TimeSpan.Zero || factorySettings.LeaseTimeout == TimeSpan.Zero || factorySettings.MaxItemsInCache == 0) { enabled = false; } else { enabled = true; } if (!this.channelCacheEnabled.HasValue) { this.channelCacheEnabled = enabled; } else { Fx.Assert(this.channelCacheEnabled.Value == enabled, "Once ChannelCacheEnabled is set, it cannot be changed!"); } }
internal void InitializeChannelCacheEnabledSetting(ActivityContext context) { if (!this.channelCacheEnabled.HasValue) { SendMessageChannelCache extension = context.GetExtension <SendMessageChannelCache>(); this.InitializeChannelCacheEnabledSetting(extension); } }
static SendMessageChannelCache CreateDefaultExtension() { SendMessageChannelCache defaultExtension = new SendMessageChannelCache(); defaultExtension.FactorySettings.LeaseTimeout = ChannelCacheDefaults.DefaultFactoryLeaseTimeout; defaultExtension.ChannelSettings.LeaseTimeout = ChannelCacheDefaults.DefaultChannelLeaseTimeout; return(defaultExtension); }
internal void InitializeChannelCacheEnabledSetting(ActivityContext context) { if (!this.channelCacheEnabled.HasValue) { SendMessageChannelCache channelCacheExtension = context.GetExtension <SendMessageChannelCache>(); Fx.Assert(channelCacheExtension != null, "channelCacheExtension must exist!"); InitializeChannelCacheEnabledSetting(channelCacheExtension); } }
internal void InitializeChannelCacheEnabledSetting(SendMessageChannelCache channelCacheExtension) { bool flag; ChannelCacheSettings factorySettings = channelCacheExtension.FactorySettings; if (((factorySettings.IdleTimeout == TimeSpan.Zero) || (factorySettings.LeaseTimeout == TimeSpan.Zero)) || (factorySettings.MaxItemsInCache == 0)) { flag = false; } else { flag = true; } if (!this.channelCacheEnabled.HasValue) { this.channelCacheEnabled = new bool?(flag); } }
static void Main(string[] args) { completeEvent = new AutoResetEvent(false); CreateClientWorkflow(); //sharing a channel cache between two workflow applications in a single app-domain. sharedChannelCache = new SendMessageChannelCache(new ChannelCacheSettings { MaxItemsInCache = 5 }, new ChannelCacheSettings { MaxItemsInCache = 5 }); WorkflowApplication workflowApp1 = new WorkflowApplication(workflow); workflowApp1.Completed = new Action<WorkflowApplicationCompletedEventArgs>(OnCompleted); workflowApp1.Extensions.Add(sharedChannelCache); WorkflowApplication workflowApp2 = new WorkflowApplication(workflow); workflowApp2.Completed = new Action<WorkflowApplicationCompletedEventArgs>(OnCompleted); workflowApp2.Extensions.Add(sharedChannelCache); //disabling the channel cache so that channels are closed after being used. SendMessageChannelCache disabledChannelCache = new SendMessageChannelCache(new ChannelCacheSettings { MaxItemsInCache = 0 }, new ChannelCacheSettings { MaxItemsInCache = 0 }); WorkflowApplication workflowApp3 = new WorkflowApplication(workflow); workflowApp3.Completed = new Action<WorkflowApplicationCompletedEventArgs>(OnCompleted); workflowApp3.Extensions.Add(disabledChannelCache); try { workflowApp1.Run(); completeEvent.WaitOne(); Console.WriteLine("Workflow 1 completed successfully."); workflowApp2.Run(); completeEvent.WaitOne(); Console.WriteLine("Workflow 2 completed successfully."); workflowApp3.Run(); completeEvent.WaitOne(); Console.WriteLine("Workflow 3 completed successfully."); } catch (Exception e) { Console.WriteLine("Workflow completed with {0}: {1}.", e.GetType().FullName, e.Message); } Console.WriteLine("To exit press ENTER."); Console.ReadLine(); }
internal void InitializeChannelCacheEnabledSetting(SendMessageChannelCache channelCacheExtension) { Fx.Assert(channelCacheExtension != null, "channelCacheExtension cannot be null!"); ChannelCacheSettings factorySettings = channelCacheExtension.FactorySettings; Fx.Assert(factorySettings != null, "FactorySettings cannot be null!"); bool enabled; if (factorySettings.IdleTimeout == TimeSpan.Zero || factorySettings.LeaseTimeout == TimeSpan.Zero || factorySettings.MaxItemsInCache == 0) { enabled = false; } else { enabled = true; } if (!this.channelCacheEnabled.HasValue) { this.channelCacheEnabled = enabled; } else { Fx.Assert(this.channelCacheEnabled.Value == enabled, "Once ChannelCacheEnabled is set, it cannot be changed!"); } }
static SendMessageChannelCache CreateDefaultExtension() { SendMessageChannelCache defaultExtension = new SendMessageChannelCache(); defaultExtension.FactorySettings.LeaseTimeout = ChannelCacheDefaults.DefaultFactoryLeaseTimeout; defaultExtension.ChannelSettings.LeaseTimeout = ChannelCacheDefaults.DefaultChannelLeaseTimeout; return defaultExtension; }
internal void InitializeChannelCacheEnabledSetting(SendMessageChannelCache channelCacheExtension) { bool flag; ChannelCacheSettings factorySettings = channelCacheExtension.FactorySettings; if (((factorySettings.IdleTimeout == TimeSpan.Zero) || (factorySettings.LeaseTimeout == TimeSpan.Zero)) || (factorySettings.MaxItemsInCache == 0)) { flag = false; } else { flag = true; } if (!this.channelCacheEnabled.HasValue) { this.channelCacheEnabled = new bool?(flag); } }