agudom
agudom

Reputation: 1

WCF Self Hosted no parallelism at first

I have a self hosted WCF service with two methods:

     public async Task<string> MethodA()
     {
         return await Task.Run(() => samplesMain.MethodA());
     }

     public async Task<string> MethodB()
     {
         return await Task.Run(() => samplesMain.MethodB());
     }

Both methods are very simple:

     public string MethodA()
     {
         Thread.Sleep(10000);
         return "A";
     }

     public string MethodB()
     {
         Thread.Sleep(10000);
         return "B";
     }

From a TestClient If the first time I call MethodA, I also call MethodB, MethodB does not start until MethodA has finished. However, once both methods have been executed at least once, subsequent parallel calls to those methods are executed in parallel.

My ServiceBehavior:

[ServiceBehavior ( ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single, UseSynchronizationContext = false ) ]

I've read that it could be due to not initially calling the "Open" method on the client, but I still don't get parallelism from the beginning. Why?

Upvotes: 0

Views: 41

Answers (0)

Related Questions