/................................................................. private void BtnBFS_Click(object sender, EventArgs e) { Thread[] SpiderThread = new Thread[n]; object[] Param = new object[n]; ThreadCount = n; for (int i = 0; i < n; i++) Param[i] = TxtURL.Lines[i].ToString(); for (int Index = 0; Index < n; Index++) { SpiderThread[Index] = new Thread(BFS); SpiderThread[Index].Name = Index.ToString(); } for (int i = 0; i < n; i++) SpiderThread[i].Start(Param[i]); for (int i = 0; i < n n; i++) SpiderThread[i].Join(); } /////............................................................ public void BFS(object Param) { try { define some variable while (UnCrawledQueue.Count >= 0 and visited <= NumC) { main process; } } }
Remove the SpiderThread[i].Join(); line. When you call Join on a thread it blocks the calling thread (in your case: the UI thread) until the thread has finished its work.
SpiderThread[i].Join();
Join
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)