public IndexedHashtable connect()
{
int lth = cxnTable.Count;
QueryThread[] queries = new QueryThread[lth];
Thread[] threads = new Thread[lth];
for (int i = 0; i < lth; i++)
{
queries[i] = new QueryThread(cxnTable.GetValue(i), "connect", new Object[0]);
//queries[i].execute();
threads[i] = new Thread(new ThreadStart(queries[i].execute));
threads[i].Start();
}
IndexedHashtable result = new IndexedHashtable(lth);
for (int i = 0; i < lth; i++)
{
string key = (string)cxnTable.GetKey(i);
threads[i].Join();
//Need to report result whether it's a connection or an exception.
if (queries[i].isExceptionResult())
{
result.Add(key,queries[i].Result);
}
else
{
result.Add(key,((Connection)cxnTable.GetValue(key)).DataSource);
}
}
//Now for all the results that failed to connect, we remove them from the connection table.
for (int i = 0; i < lth; i++)
{
if (queries[i].isExceptionResult())
{
string key = (string)cxnTable.GetKey(i);
cxnTable.Remove(key);
cxnTable.Add(key, queries[i].Result);
}
}
return result;
}