I have an telephony application, in which the server has 4 ports. That means the application can only take 4 calls at the same time. However I have many calls in the queue say 50, for example.
So my logic is take 4 from the queue, remaining 46. After the first 4 completes, take the next 4 from the remaining 46. Thus the remaining will be 42, keep going...
If one of call failed, it should be kicked back to the queue. Please check my logic..
string[] waitedCallNumbers = new string[50];
// get the numbers from somewhere
for (int i = 0; i < 4; i++)
{
string dialNumber = waitedCallNumbers[i];
TestRun(dialNumber);
// not sure how to deal with queue--waitedCallNumbers after call
}
//This will start the threads that run the test calls
public async void TestRun(string dialNumber)
{
await Task.Run(() => MakeCall(s_TelephonyServer,dialNumber));
}
private void MakeCall(TelephonyServer ts,string dialNumber)
{
try
{
DialResult dr = Dial(dialNumber);
// log result...
}
catch()
finally
{
// dispose all resources
}
}
Thanks.
No comments:
Post a Comment