In Image whole scenario is explained. that the multiple number of clients calls a function name with call(), to service1. and each client call function simultaneously. so service1 identity that function call from which client, and each client calls a function (call()) at a time more than 10times on miliseconds difference, and my requirement is, at what order client call the function, in the same order call function should execute, and parallel this should work for all clients.
Image link.
click here
current Implemetation working:
client 1
Client2
* * *
client N
client1 calls function 10 times at 10miliseconds difference.
client1.call(1);
client1.call(2);
client1.call(3);
client1.call(4);
client1.call(5);
client1.call(6);
client1.call(7);
client1.call(8);
client1.call(9);
client1.call(10);
All clients simultaneously call function to service 1
Service1 Call();
And then service1 calls the call() function whose implementation is in service2.
Service 2 (Wcf service)
public int Call(int number)
{
Console.WriteLine("The number in parameter pass :" + Number);
return number;
}
Output Comes
The number in parameter pass :1
The number in parameter pass :2
The number in parameter pass :5
The number in parameter pass :6
The number in parameter pass :7
The number in parameter pass :8
The number in parameter pass :3
The number in parameter pass :4
The number in parameter pass :10
The number in parameter pass :9
In output order disturb, as required output is
The number in parameter pass :1
The number in parameter pass :2
The number in parameter pass :3
The number in parameter pass :4
The number in parameter pass :5
The number in parameter pass :6
The number in parameter pass :7
The number in parameter pass :8
The number in parameter pass :9
The number in parameter pass :10
This is happening due to call() function simultaneously calls 10times and call(3) and call(4) takes time to insert data in database and call(5), call(6) complete first.
In Nutshell:
How do i make a queues for each client, so that order does not disturb for each client.
I tried like this ThreadPool.QueueUserWorkItem(state => Call(1)), but QueueUserWorkItem will return only Boolean vlaue, but i need to get in return specific custom list. which is return by call() function.