SendMessageChannelCache 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 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);
備註
如需通道處理站的詳細資訊,請參閱 ChannelFactory 和 ChannelFactory<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 未使用組態中所定義端點的活動。 不過,如果您想要在此案例中開啟快取,請呼叫這個建構函式, allowUnsafeCaching
並將 參數設定為 true
。 接著,請將這個類別的新執行個體加入工作流程服務主機或工作流程執行個體,做為擴充。
如需通道處理站的詳細資訊,請參閱 ChannelFactory 和 ChannelFactory<TChannel>。