This is a mirror of official site: http://jasper-net.blogspot.com/

DispatcherFrame. Look in-Depth

| Tuesday, February 1, 2011
Introduction

Have you ever wondered what DispatcherFrame exactly is? This article will explain it to you  

DispatcherFrame. Look in-Depth

I think that most all of you heard about DispatcherFrame. Let’s try to understand what is it and where it can be used? MSDN said: “Represent an execution loop in the Dispatcher”. Not enough info to understand and use it as I think. Also, there is example of very usefull procedure, but also, not obvious to understand. Here is it:

[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;
}
 
This procedure is DoEvents. As you can guess from it’s title – it force events to be performed. So, let’s understand DispatcherFrame and how this method works.
Let’s start with Dispatcher class. I think everybody who works with WPF knows what it is. It is a class that works with UI thread in WPF. It contains queue of items that should be performed. I hope that everybody knows about Dispatcher and I don’t need to describe it in details.

Read more: Codeproject

Posted via email from Jasper-net

0 comments: