Share via


MessageQueue.EnableConnectionCache 屬性

定義

取得或設定值,指出應用程式是否會維持連接的快取。

public:
 static property bool EnableConnectionCache { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public static bool EnableConnectionCache { get; set; }
[<System.ComponentModel.Browsable(false)>]
static member EnableConnectionCache : bool with get, set
Public Shared Property EnableConnectionCache As Boolean

屬性值

true 表示建立並使用連接快取,否則為 false

屬性

範例

下列程式代碼範例會取得並設定消息佇列 EnableConnectionCache 屬性的值。

// Set the MessageQueue.EnableConnectionCache property value.
MessageQueue.EnableConnectionCache = false;

// Display the new value of the MessageQueue.EnableConnectionCache
// property.
Console.WriteLine("MessageQueue.EnableConnectionCache: {0}",
    MessageQueue.EnableConnectionCache);

備註

連接快取是包含佇列讀取或寫入句柄之結構的參考清單。 當 是 trueEnableConnectionCache,每次MessageQueue呼叫 Send(Object)PeekReceive時,都會從快取借用句柄,而不是開啟新的句柄。 這可以改善效能。 使用連線快取也會隔離網路 MessageQueue 拓撲中的變更。

如果您在連線快取已滿時建立佇列的新連線,則會 MessageQueue 以新的連線覆寫最近存取的最小結構。 例如,如果所使用的佇列格式名稱已變更,讓先前的讀取和寫入句柄不再有效,您可以完全 ClearConnectionCache清除快取。

下表顯示此屬性是否可在各種工作組模式中使用。

工作組模式 可用
本機電腦
本機計算機和直接格式名稱
遠端電腦
遠端電腦和直接格式名稱

適用於

另請參閱