本文介绍了如何在多线程应用程序中防止冻结表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我编写了一个多线程应用程序,用于通过C#从网页(例如在线社交网络)中提取朋友列表。不幸的是My Form挂起来并且没有回应任何事情。(冻结)我该怎么办?

我将非常感谢你的帮助。

非常感谢。



我的代码是:

Hi,
I wrote An multi-thread application to extract list of friends from a web page such as an online social network by C#. unfortunately My Form hangs and dont response to anything.(freezing) what could i do?
I would appreciate your help.
thanks a lot.

my Code is:

/.................................................................
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;
}
}
}

推荐答案


这篇关于如何在多线程应用程序中防止冻结表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 19:04