长时间 wpf 界面绘制操作期间的繁忙指示器
我正在使用一些需要一些时间(约 3-5 秒)才能渲染的第 3 方组件 - 经过分析后我得出结论,大部分时间都浪费在这些控件的 MeasureOverride 和 Render 方法中...我无法编辑源代码这些组件的代码。 问题是..我可以在“绘制”界面时显示忙碌指示器吗?在WPF中可以吗?
I am using some 3rd party components that take some time (~3-5s) to render - after profiling I've come to conclusion that most of the time is wasted in MeasureOverride and Render methods of those controls... I cannot edit source code of those components.
The problem is .. can I display a busy indicator while the interface is being 'drawn' ? Is it possible in WPF?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,你不能,嗯,不是以一种好的方式。
UI 线程正忙于渲染 - 绘制繁忙指示器将需要同一线程来绘制指示器。
现在,您可以从另一个线程创建第二个窗口(可能是半透明的)并将该窗口放置在冻结窗口的顶部,但这很难做到正确,您必须处理诸如用户移动窗口之类的事情(并且您永远不会知道窗口已移动,因为接受移动通知的线程正忙)或两个窗口之间弹出的其他应用程序
此外,这可能会干扰第一个窗口的绘制,并且通常只需要许多极端情况即可得到正确的。
No you can't, well, not in a good way.
The UI thread is busy rendering - drawing the busy indicator would require that same thread to draw the indicator instead.
Now, you can create a second window (maybe semi-transparent) from another thread and place that window on top of your frozen window, but that is very difficult to get right, you have to deal with things like the user moving the window (and you will never know the window moved because the thread that accept the move notifications is busy) or other application poping up between your two windows
Also this is likely to interfere with the first window drawing and generally just has to many corner cases to ever get right.