public bool SearchWebSites(string url) { DateTime lStarted = DateTime.Now; _pages = new ArrayList(); // split the urls string to an array string[] lURLs = url.Split('\r'); int lIdx; searchTitle st;
// create the Thread array Thread[] t = new Thread[lURLs.Length]; for (lIdx = 0; lIdx < lURLs.Length; lIdx++) { // create a WebPage object for each url st = new searchTitle(lURLs[lIdx]); // add it to the _pages ArrayList _pages.Add(st);
t[lIdx] = new Thread(new ThreadStart(st.search)); // start the Thread object, which executes the search(). t[lIdx].Start(); t[lIdx].IsBackground = true; } for (lIdx = 0; lIdx < _pages.Count; lIdx++) { // waiting for all the Threads to finish. t[lIdx].Join(); } // stop the timer. _timeSpent = DateTime.Now.Subtract(lStarted); Operation op = new Operation(); op.DeleteNowDelete();
{
DateTime lStarted = DateTime.Now;
_pages = new ArrayList(); // split the urls string to an array
string[] lURLs = url.Split('\r');
int lIdx;
searchTitle st;
// create the Thread array
Thread[] t = new Thread[lURLs.Length]; for (lIdx = 0; lIdx < lURLs.Length; lIdx++)
{
// create a WebPage object for each url
st = new searchTitle(lURLs[lIdx]);
// add it to the _pages ArrayList
_pages.Add(st);
t[lIdx] = new Thread(new ThreadStart(st.search));
// start the Thread object, which executes the search().
t[lIdx].Start();
t[lIdx].IsBackground = true;
} for (lIdx = 0; lIdx < _pages.Count; lIdx++)
{
// waiting for all the Threads to finish.
t[lIdx].Join();
} // stop the timer.
_timeSpent = DateTime.Now.Subtract(lStarted); Operation op = new Operation();
op.DeleteNowDelete();
return true;
}
这里该怎么设置线程数量为20啊??急
我现在这么弄,很多数据都不准确,是不是一次执行的线程多了,反应不过来。