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 实例(MaxItemsInCache 值为 0)的这个构造函数,您可以选择只使用通道工厂缓存并禁用通道缓存。 要完全禁用通道工厂缓存和通道缓存的缓存,请将 factorySettings 参数传递给已初始化为 ChannelCacheSettings 实例(MaxItemsInCache 值为 0)的这个构造函数。 注意:您不能在通道工厂缓存禁用时启用通道缓存。

适用于

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 不使用配置中定义的终结点的活动。 However, if you want to turn caching on in this case call this constructor with the allowUnsafeCaching parameter set to true. 接下来,将此类的新实例作为扩展添加到工作流服务主机或工作流实例。

有关通道工厂的更多信息,请参见 ChannelFactoryChannelFactory<TChannel>

适用于