WinForm应用程序UI在长期运行过程中挂起我有一个windows窗体应用程序,在这个应用程序上我需要使用一个for循环,它有大量的远程调用(大约2000-3000次调用),在执行for循环时,我放松了对Form和Form控件的控制,因为它变成了一个大进程,有时它显示出“没有响应”-但是如果我等了很长时间,它又回来了,我想我需要使用一些线程模型来解决这个问题,有什么办法解决这个问题吗?
3 回答
30秒到达战场
TA贡献1828条经验 获得超6个赞
private voidForm_Load(object sender, EventArgs e) { MethodInvoker mk = delegate { //your job }; mk.BeginInvoke(callbackfunction, null); } private void callbackfunction(IAsyncResult res) { // it will be called when your job finishes. }
qq_花开花谢_0
TA贡献1835条经验 获得超7个赞
Application.DoEvents(); //repaint or respond to msg
foreach (DirectoryInfo subDir in dirInfo.EnumerateDirectories()){ count = count + 1; listBoxControl4.Items.Add(count.ToString() + ":" + subDir.FullName); Application.DoEvents(); //allow repaint to see status ProduceListing(subDir, " ");}
- 3 回答
- 0 关注
- 715 浏览
添加回答
举报
0/150
提交
取消