示例#1
0
            public void QueryMethod(string daoName, string methodName, object[] args)
            {
                ArrayList queries = new ArrayList(myCset.Count);
                ArrayList threads = new ArrayList(myCset.Count);

                foreach (KeyValuePair<string, AbstractConnection> kvp in myCset.Connections)
                {
                    AbstractConnection c = kvp.Value;
                    if (skipThisConnection(c))
                    {
                        continue;
                    }
                    object dao = getDao(daoName, c);
                    QueryThread q = new QueryThread(c.DataSource.SiteId.Id, dao, methodName, args);
                    Thread t = new Thread(new ThreadStart(q.execute));
                    queries.Add(q);
                    threads.Add(t);
                    t.Start();
                }
                for (int i = 0; i < threads.Count; i++)
                {
                    ((Thread)threads[i]).Join();
                }
                myCset.Results = new IndexedHashtable();
                myCset.Exceptions = null;
                for (int i = 0; i < queries.Count; i++)
                {
                    QueryThread t = (QueryThread)queries[i];
                    if (t.isExceptionResult())
                    {
                        handleException(t);
                        if (myCset.Exceptions == null)
                        {
                            myCset.Exceptions = new IndexedHashtable();
                        }
                        myCset.Exceptions.Add(t.Id, t.Result);
                    }
                    else
                    {
                        handleNonException(t);
                        myCset.Results.Add(t.Id, t.Result);
                    }
                }
            }