DispatcherService CurrentDispatcher Extension

Topics: Feature requests
Jun 20, 2012 at 10:57 PM

Hi Geert,

could you PLEASE introduce a virtual property CurrentDispatcher which i can override for my custom needs. My plugin has troubles with finding the correct dispatcher because in DispatcherHelper the Application object is null.......

	public class DispatcherService : IDispatcherService
	{
		public void Invoke(Action action)
		{
			Argument.IsNotNull("action", action);
			Dispatcher dispatcher = this.CurrentDispatcher;
			if (dispatcher != null && !dispatcher.CheckAccess())
			{
				dispatcher.Invoke(action, null);
				return;
			}
			action();
		}
		public void Invoke(Delegate method, params object[] args)
		{
			Argument.IsNotNull("method", method);
			Dispatcher dispatcher = this.CurrentDispatcher;
			if (dispatcher != null && !dispatcher.CheckAccess())
			{
				dispatcher.Invoke(method, args);
				return;
			}
			method.DynamicInvoke(args);
		}
		public void BeginInvoke(Action action)
		{
			Argument.IsNotNull("action", action);
			Dispatcher dispatcher = this.CurrentDispatcher;
			if (dispatcher != null && !dispatcher.CheckAccess())
			{
				dispatcher.BeginInvoke(action, null);
				return;
			}
			action();
		}
		public void BeginInvoke(Delegate method, params object[] args)
		{
			Argument.IsNotNull("method", method);
			Dispatcher dispatcher = this.CurrentDispatcher;
			if (dispatcher != null && !dispatcher.CheckAccess())
			{
				dispatcher.BeginInvoke(method, args);
				return;
			}
			method.DynamicInvoke(args);
		}

                  protected virtual Dispatcher CurrentDispatcher
                  {
                           get
                           {

                                 return DispatcherHelper.CurrentDispatcher;
                           }
                  }
	}

Many Thanks!!!!!

Coordinator
Jun 21, 2012 at 6:15 AM

Done, just committed. I will release a new nightly build with all the new features tonight.

Jun 21, 2012 at 8:35 AM

Thanks a lot!

Coordinator
Jun 21, 2012 at 9:47 PM

We released a new version with this fix (via NuGet). Tomorrow, we will release RC1, but we want to await some feedback.