ShowDialog的无阻塞来电 [英] ShowDialog without Blocking Caller

查看:122
本文介绍了ShowDialog的无阻塞来电的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个强烈的命名程序集。

I have a strong named assembly.

在......但只有几分,并用不同的用途本已经被问。

This has been asked before...but only sort of and with a different purpose.

我有一个表格基类。当实现类设置在基类中的属性 IsBusy 。我想阻止与表格的所有交互(设置启用=假是不够的 - 我也想阻止移动,缩放,关闭,等....我不希望我的控制需要照看残疾时, IsBusy ==真),并显示在前面弹出装载形式(透明,无国界的加载动画的形式)。

I have a Form base class. When the implementing class sets a property on the base class IsBusy. I want to block all interaction with the Form (setting Enabled = false is not enough - I also want to block moving, resizing, closing, etc....and I don't want my controls to look disabled when IsBusy == true) and show a popup loading form in front (a transparent, borderless form with a loading animation).

在我的加载动画的形式调用的ShowDialog的伎俩阻断交互调用窗体上......但很明显,我也想调用的形式code继续执行的条款。

Calling ShowDialog on my loading animation form does the trick in terms of blocking interaction on the calling form...but obviously I also want the calling forms code to continue executing.

现在,我用新的LoadingForm()。显示(),然后在我的呼唤形态,如果 IsBusy ==真我苏preSS处理的WndProc所有的WndProc消息......但我不喜欢这种方式。它$ P $重画过,我不想pvents的形式。

Right now I'm using new LoadingForm().Show(), then handling WndProc on my calling Form and if IsBusy == true I supress all WndProc messages...but I don't like this approach. It prevents the form from repainting too, which I don't want.

我不会介意的WndProc方法这么多,如果我知道所有的不同类型的消息,让通过,让正确的重新粉刷,而 IsBusy ==真 ...但我不知道。

I wouldn't mind the WndProc approach so much if I knew all the different types of messages to let through to allow correct repainting while IsBusy == true...but I don't.

所以,我的问题是:

有没有更好的解决办法?

Is there a better solution?

罐有人告诉什么的WndProc消息我应该让过?或者,在哪里可以找到一个词汇?

Cans someone tell what WndProc messages I should let through? Or where to find a glossary?

感谢。

推荐答案

我结束了BeginInvoke'ing一个ShowDialog的:

I ended up BeginInvoke'ing a ShowDialog:

myForm.BeginInvoke(new Action(() => new LoadingForm().ShowDialog()));

这具有让$ C $℃后该行继续运行且仍然阻止与myForm的所有交互的期望的效果。

that has the desired effect of letting code after that line continue to run and still blocking all interaction with myForm.

这篇关于ShowDialog的无阻塞来电的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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