Windows窗体应用程序 - 慢速/不响应的用户界面慢速、窗体、用户界面、应用程序

2023-09-04 04:12:35 作者:心天真

可能重复:   C# WinForm应用程序 - 在长时间运行的操作 UI挂起

Possible Duplicate: C# WinForm Application - UI Hangs during Long-Running Operation

我在使用C#和.NET Framework 4.0的Windows窗体应用程序。我有一个问题,同时该程序正在做的工作,我不能走动的窗口,如果我尽量减少它,我不能拿回来。我想这是因为我做工作,该UI运行在同一个线程。

I created a Windows Form Application using C# and .NET Framework 4.0. I'm having a problem where while the program is doing work I can't move around the window and if I minimize it I can't get it to come back. I assume this is because I'm doing work on the same thread that the UI is running on.

难道这是原因是什么?如果是的话我怎么解决这个问题?

Could this be the cause? If so how do I fix it?

推荐答案

如果你不想进入线程和线程的内部,我会建议使用BackgroundWorker控制,做你的任务。背景工人控件封装了大量线程的东西在背后给你一个干净的编程接口。

If you don't want to get into the internals of threads and threading, I would recommend using the BackgroundWorker control to do your task. The Background worker control encapsulates a lot of threading stuff behind the scenes to give you a clean programming interface.

下面这个链接可以帮助你(我写的)

The following link might help you (written by me)

正确的使用方法BackgroundWorker的