. Net – multithreaded self managed WCF service

It seems that WCF uses only one thread when using self - hosting I want to use multiple threads or some kind of thread pool for this Can I use self managed configuration or do I need to use IIS?

Solution

If you self - manage services in a UI application with default service behavior settings, you may see the behavior you are describing The default service behavior uses the synchronization context When the service host is started in the UI thread (WinForms, WPF), all requests are routed to the public window message loop = > all requests are processed sequentially by the UI thread

In any other case (including manually setting [servicebehavior (usesynchronizationcontext = false)] for the service hosted in the UI thread), the service host schedules a new thread from the thread pool for each request There are some further differences between instance - based context mode and concurrency mode, but using the default settings, you will see the behavior I describe

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>