1. 程式人生 > >(WCF) 多執行緒 (Multi-threading) 和 併發性 (Concurency)

(WCF) 多執行緒 (Multi-threading) 和 併發性 (Concurency)

問題:WCF 有個Server端,還有個Client端,他們之間是如何進行併發,多執行緒通訊的呢?多個Client端同時訪問Server,如何保證Server端的操作執行緒安全呢?

 

在理解WCF Concurency之前,首先需要理解 WCF instance management

 這裡有篇很好的文章可以參考:

https://www.codeproject.com/Articles/86007/3-ways-to-do-WCF-instance-management-Per-call-Per

Following are different ways by which you can create WCF instances:

  • Create a new WCF service instance on every WCF client method call.
  • Only one WCF service instance should be created for every WCF client session.
  • Only one global WCF service instance should be created for all WCF clients.

To meet the above scenarios, WCF has provided three ways by which you can control WCF service instances:

  • Per call
  • Per session
  • Single instance

 

 https://www.codeproject.com/articles/89858/%2fArticles%2f89858%2fWCF-Concurrency-Single-Multiple-and-Reentrant-and