如何同时运行两个表单? [英] How to run two form at the same time?

查看:69
本文介绍了如何同时运行两个表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在c#中运行两个表单。但我想要的是那个。如果其他形式是冻结或装载。另一种形式仍然有效。假设第一个表单是上传文件,它会因大量上传文件而冻结,而另一个表单会计算上传的分钟数。如何编码?我研究并在c#中进行和实验,但它不起作用。请帮助我。

I want to run a two form in the c#. but what i want is that. if the other form is freezing or loading. the other form are still working. assuming the first form is upload the file and it will freeze due to a large file of upload while the other form will count the elapse minute of uploading. How to code that? i research and do and experiment in c# but it doesn't work. pls help me.

推荐答案

由于通常所有表单都在用户界面线程(又称主线程)上运行,因此您的第一个表单不应该首先冻结。



相反,重负荷应该由一个单独的线程解除: BackgroundWorker [ ^ ]是您的朋友。如果您想阻止用户通过第一个表单进行干扰,您可以将第二个表单设为模式表单 [ ^ ]。然后,您的BackgroundWorker 报告进度 [ ^ ]到第二种形式。
Since usually all Forms run on the "User Interface Thread" a.k.a. "Main Thread", your first form should not freeze in the first place.

Instead, the heavy load should be lifted by a separate thread: BackgroundWorker[^] is your friend here. If you want to prevent user from interfering via first form, you can make the second a modal form[^]. Your BackgroundWorker then reports progress[^] to the second form.


这篇关于如何同时运行两个表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆