public void outgoingResult(string index, string result)
{
if (!string.IsNullOrEmpty(Master))
{
try
{
// if count < number of tasks for this machine, put the result into the table
// if count == number of tasks for this machine, build a big message and send it to master
int indexNum = Int32.Parse(index);
if (TaskIndexList.Contains(indexNum))
{
if (!ResultCollection.ContainsKey(index))
{
ResultCollection.Add(index, result);
SubResultCollection.Add(index, result);
if (SubResultCollection.Count == 1000 || ResultCollection.Count == TaskIndexList.Count)
{
string[] temp = Master.Split(':');
string theIP = temp[0];
string thePort = temp[1];
if (SubResultCollection.Count == 1000 && ResultCollection.Count != TaskIndexList.Count)
{
AsynchronousClient client = new AsynchronousClient();
client.SetSingleMsg(theIP, thePort, createParallelResultMessage(SubResultCollection));
Thread t = new Thread(new ThreadStart(client.SendSingleClient));
t.IsBackground = true;
t.Start();
SubResultCollection.Clear();
}
if (ResultCollection.Count == TaskIndexList.Count)
{
AsynchronousClient client = new AsynchronousClient();
client.SetSingleMsg(theIP, thePort, createParallelResultMessage(SubResultCollection));
Thread t = new Thread(new ThreadStart(client.SendSingleClient));
t.IsBackground = true;
t.Start();
Thread.Sleep(100);
TaskIndexList.Clear();
ResultCollection.Clear();
SubResultCollection.Clear();
}
}
}
}
}
catch (Exception e)
{ Console.WriteLine(e.ToString()); }
}
}
//public void PeerGone(string IPPort)