first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

WPF and WCF: The Decorator Pattern and Dispatcher.CurrentDispatcher

/* Push dispatching into the service layer with a decorator pattern. */

public class MySvcDecorator : IMySvc { private readonly IMySvc _mysvc; private readonly Dispatcher _current = Dispatcher.CurrentDispatcher;

public MySvcDecorator(IMySvc mysvc){//set _mysvc here...;}
public Event Action<T> HeyGui;
void MySvcEventHandler(T mydata)
{
    Action dispatch = () => { if(HeyGui != null) HeyGui(mydata); }
    _current.BeginInvoke(DispatcherPriority.DataBind, dispatch);
}

}

mod date: 2010-02-15T19:18:20.000Z