SendMessageChannelCache Constructor (ChannelCacheSettings, ChannelCacheSettings)

.NET Framework (current version)
 

Initializes a new instance of the SendMessageChannelCache class with custom factory cache and channel cache settings.

Namespace:   System.ServiceModel.Activities
Assembly:  System.ServiceModel.Activities (in System.ServiceModel.Activities.dll)

public SendMessageChannelCache(
	ChannelCacheSettings factorySettings,
	ChannelCacheSettings channelSettings
)

Parameters

factorySettings
Type: System.ServiceModel.Activities.ChannelCacheSettings

The cache settings for cached channel factories.

channelSettings
Type: System.ServiceModel.Activities.ChannelCacheSettings

The cache settings for cached channels.

For more information about channel factories, see ChannelFactory and ChannelFactory<TChannel>.

You can choose to use only the channel factory cache and disable the channel cache by passing the channelSettings parameter to this constructor initialized to a ChannelCacheSettings instance with a MaxItemsInCache value of 0. To disable the cache completely for both the channel factory cache and the channel cache, pass the factorySettings parameter to this constructor initialized to a ChannelCacheSettings instance with a MaxItemsInCache value of 0. Note that you cannot turn the channel cache on if the channel factory cache is disabled.

The following example shows how to use the SendMessageChannelCache class to share a channel cache between two workflow applications in a single app domain.


//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);

.NET Framework
Available since 4.0
Return to top
Show: