Click here to Skip to main content
15,911,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've created the following service:
C#
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
public class ActivatorService : IActivatorService

private bool function()
{
    Thread.Sleep(60000);
    return false;
}

I try to call it from 2 - 3 clients, but no client can call the function until another client exited from it.

Why is the service not calling the method concurrently?
Posted
Updated 16-Mar-12 15:00pm
v2

Take a look at this article from Kenny W InstanceContextMode, ConcurrencyMode, and Server-side Threading[^]. Hope it helps.
 
Share this answer
 
Comments
impeham 17-Mar-12 10:43am    
Well, i read this article during my searches in google for a solution, but it doesn't help since it says that setting the ServiceBehavior attribute's parameters like i did should work, and in such case i should have hit the breakpoint inside "function" twice when i called it from two different processes and it does not work in parallel - only after the 60 secs period i get the call from the other process.
By the way - i'm not using IIS for hosting but doing it with a simple console application.
Solved by creating the ServiceHost in a different thread.
Creating the host in a WinForm application did not allow it to use multithreading.
 
Share this answer
 
InstanceContextMode.Single is the problem change it to percall or persession
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900