WCF in a Winforms application - is it always single-threaded?

I have a Winforms application that provides a WCF service.

From IIS, I am trying to use a service. On two different computers, I'm trying to call test1.aspx , which in turn calls WCF inside a Winforms application.

 test1.aspx => from computer 1 => First Call test1.aspx => from computer 2 => Second Call 

I see that WCF is single-threaded, and before it starts processing CALL 2, it must finish processing CALL 1.

 [ServiceBehavior(IncludeExceptionDetailInFaults = true, ConcurrencyMode=ConcurrencyMode.Multiple, InstanceContextMode=InstanceContextMode.PerSession)] 

I have Windows Server 2008 R2 and IIS 7.5

Can anybody help me?

+4
source share
1 answer

WCF behaves differently when a service is hosted in a user interface thread, which is probably your business. By default, WCF processing is connected to the Windows message loop, so the request processing will not only become sequential, but also stop processing all events in the WinForms interface (the application will freeze).

To avoid this behavior, you must explicitly say that you do not want to host the service in the user interface thread:

 [ServiceBehavior(UseSynchronizationContext = false)] 
+10
source

Source: https://habr.com/ru/post/1286352/


All Articles