通过


SendMessageChannelCache 构造函数

定义

初始化 SendMessageChannelCache 类的新实例。

重载

名称 说明
SendMessageChannelCache()

使用默认工厂缓存和通道缓存设置初始化类的新实例 SendMessageChannelCache

SendMessageChannelCache(ChannelCacheSettings, ChannelCacheSettings)

使用自定义工厂缓存和通道缓存设置初始化类的新实例 SendMessageChannelCache

SendMessageChannelCache(ChannelCacheSettings, ChannelCacheSettings, Boolean)

使用自定义工厂缓存设置、自定义通道缓存设置以及指示是否打开缓存的值初始化类的新实例 SendMessageChannelCache

SendMessageChannelCache()

使用默认工厂缓存和通道缓存设置初始化类的新实例 SendMessageChannelCache

public:
 SendMessageChannelCache();
public SendMessageChannelCache();
Public Sub New ()

适用于

SendMessageChannelCache(ChannelCacheSettings, ChannelCacheSettings)

使用自定义工厂缓存和通道缓存设置初始化类的新实例 SendMessageChannelCache

public:
 SendMessageChannelCache(System::ServiceModel::Activities::ChannelCacheSettings ^ factorySettings, System::ServiceModel::Activities::ChannelCacheSettings ^ channelSettings);
public SendMessageChannelCache(System.ServiceModel.Activities.ChannelCacheSettings factorySettings, System.ServiceModel.Activities.ChannelCacheSettings channelSettings);
new System.ServiceModel.Activities.SendMessageChannelCache : System.ServiceModel.Activities.ChannelCacheSettings * System.ServiceModel.Activities.ChannelCacheSettings -> System.ServiceModel.Activities.SendMessageChannelCache
Public Sub New (factorySettings As ChannelCacheSettings, channelSettings As ChannelCacheSettings)

参数

factorySettings
ChannelCacheSettings

缓存通道工厂的缓存设置。

channelSettings
ChannelCacheSettings

缓存通道的缓存设置。

示例

以下示例演示如何使用 SendMessageChannelCache 类在单个应用域中的两个工作流应用程序之间共享通道缓存。


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

注解

有关通道工厂的详细信息,请参阅 ChannelFactoryChannelFactory<TChannel>

可以选择仅使用通道工厂缓存,并通过将参数传递给 channelSettings 初始化为 ChannelCacheSettings 值为 0 的实例 MaxItemsInCache 的此构造函数来禁用通道缓存。 若要完全禁用通道工厂缓存和通道缓存的缓存,请将 factorySettings 参数传递给初始化 ChannelCacheSettings 为值为 0 的实例 MaxItemsInCache 的此构造函数。 请注意,如果禁用通道工厂缓存,则无法打开通道缓存。

适用于

SendMessageChannelCache(ChannelCacheSettings, ChannelCacheSettings, Boolean)

使用自定义工厂缓存设置、自定义通道缓存设置以及指示是否打开缓存的值初始化类的新实例 SendMessageChannelCache

public:
 SendMessageChannelCache(System::ServiceModel::Activities::ChannelCacheSettings ^ factorySettings, System::ServiceModel::Activities::ChannelCacheSettings ^ channelSettings, bool allowUnsafeCaching);
public SendMessageChannelCache(System.ServiceModel.Activities.ChannelCacheSettings factorySettings, System.ServiceModel.Activities.ChannelCacheSettings channelSettings, bool allowUnsafeCaching);
new System.ServiceModel.Activities.SendMessageChannelCache : System.ServiceModel.Activities.ChannelCacheSettings * System.ServiceModel.Activities.ChannelCacheSettings * bool -> System.ServiceModel.Activities.SendMessageChannelCache
Public Sub New (factorySettings As ChannelCacheSettings, channelSettings As ChannelCacheSettings, allowUnsafeCaching As Boolean)

参数

factorySettings
ChannelCacheSettings

缓存通道工厂的缓存设置。

channelSettings
ChannelCacheSettings

缓存通道的缓存设置。

allowUnsafeCaching
Boolean

true 打开缓存;否则,为 false.

注解

默认情况下,缓存仅适用于 Send 不使用配置中定义的终结点的活动。 但是,如果要在此例中打开缓存,请调用此构造函数, allowUnsafeCaching 并将参数设置为 true. 接下来,将此类的新实例作为扩展添加到工作流服务主机或工作流实例。

有关通道工厂的详细信息,请参阅 ChannelFactoryChannelFactory<TChannel>

适用于