是否有可能使用的ShowDialog不阻塞所有形式的? [英] Is it possible to use ShowDialog without blocking all forms?

查看:1444
本文介绍了是否有可能使用的ShowDialog不阻塞所有形式的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我可以解释这显然不够。我有我的主要形式(A)和它打开使用form.Show 1子窗体(B),(),并使用form.Show第二个孩子的形式(C)()。现在我想子窗体B使用form.ShowDialog打开窗体(D)()。当我做到这一点,块构成A和C型为好。有没有办法打开一个模式对话框,并只有它阻止打开它的形式?

I hope I can explain this clearly enough. I have my main form (A) and it opens 1 child form (B) using form.Show() and a second child form (C) using form.Show(). Now I want child form B to open a form (D) using form.ShowDialog(). When I do this, it blocks form A and form C as well. Is there a way to open a modal dialog and only have it block the form that opened it?

推荐答案

如果你从A和C单独的线程运行表B,ShowDialog的调用将只阻塞线程。显然,这不是当然的工作琐碎的投资。

If you run Form B on a separate thread from A and C, the ShowDialog call will only block that thread. Clearly, that's not a trivial investment of work of course.

您可以在对话框不是通过简单地在一个单独的线程运行的形式D的ShowDialog的调用阻止任何线程的。这就要求同一种工作,但要少得多吧,因为你只有一种形式运行关闭应用程序的主线程的。

You can have the dialog not block any threads at all by simply running Form D's ShowDialog call on a separate thread. This requires the same kind of work, but much less of it, as you'll only have one form running off of your app's main thread.

这篇关于是否有可能使用的ShowDialog不阻塞所有形式的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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