WPFでWindows FormのApplication.DoEventsメソッドと同様に長時間かかる処理の間にUIのイベントを処理させるには、下記のように行う。(MSDNより)
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public void DoEvents()
{
DispatcherFrame frame = new DispatcherFrame();
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
new DispatcherOperationCallback(ExitFrame), frame);
Dispatcher.PushFrame(frame);
}public object ExitFrame(object f)
{
((DispatcherFrame)f).Continue = false;return null;
}
Last 5 posts in .Net Framework
- .Net FrameworkのUriエンコードメソッドの違い - July 16th, 2010
- WCFを使ってXML-RPC通信を行うには - June 10th, 2010
- Visual Studio 2010でjQueryのインテリセンスが効かなかったので - May 11th, 2010