busy indicator during long wpf interface drawing operation

|▌冷眼眸甩不掉的悲伤 提交于 2020-02-25 09:04:08

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3653668/busy-indicator-during-long-wpf-interface-drawing-operation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!