我有一個連接到多個客戶端的WCF服務。 服務的配置如下:多線程環境下的OperationContext.Current.SessionId
ServiceBehavior(
InstanceContextMode = InstanceContextMode.Single,
UseSynchronizationContext = false,
...
在我使用標識使用OperationContext.Current.SessionId客戶服務
。
public void Register()
{
Debug.WriteLine(OperationContext.Current.SessionId);
}
試想以下情形: - 客戶端1通話記錄 - 運行服務註冊在線程1 - 在一定時間後客戶端2調用註冊 - 運行服務註冊也是線程1(這在理論上是可能的,沒有?)
明知OperationContext.Current是ThreadStatic, 什麼顯示第二個電話:
- 會議1,因爲OperationContext.Current已經在第一次調用
- 或者Session 2中設置。
預先感謝您...
感謝您的博客條目,非常有幫助。 –