WPF : Dispatcher processing has been suspended, but messages are still being processed

青春壹個敷衍的年華 提交于 2019-11-29 03:13:27
Dave Tillman

This answer describes the same situation as yours. (It references this answer on a different website).

The dispatcher processing is suspended to avoid reentrancy problems when updating the visual tree.

If you really need to display a message box in response to your "Row Loaded" event, you need to defer the call using `Dispatcher.BeginInvoke().

So, replace:

MessageBox.Show(((RadGridView)sender).Columns.Count.ToString(CultureInfo.InvariantCulture));

with:

var msg = ((RadGridView)sender).Columns.Count.ToString(CultureInfo.InvariantCulture);
Dispatcher.BeginInvoke(new Action(() => MessageBox.Show(msg)));

If this code is in a WPF object, then the Dispatcher property is available. Otherwise, you need to get it from somewhere else.

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