Created
July 5, 2010 15:22
-
-
Save meklarian/464458 to your computer and use it in GitHub Desktop.
Extension Method Class to patch a function and return a lambda that reroutes through a WPF/Silverlight Dispatcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net; | |
using System.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Documents; | |
using System.Windows.Ink; | |
using System.Windows.Input; | |
using System.Windows.Media; | |
using System.Windows.Media.Animation; | |
using System.Windows.Shapes; | |
using System.Windows.Threading; | |
namespace YourFavoriteNamespace | |
{ | |
public static class Dispatch | |
{ | |
public static Action<T> Route<T>(this Dispatcher disp, Action<T> Original) | |
{ | |
return ((a) => | |
{ | |
disp.BeginInvoke(Original, new object[] { a }); | |
}); | |
} | |
public static Action<T1, T2> Route<T1, T2>(this Dispatcher disp, Action<T1, T2> Original) | |
{ | |
return ((a, b) => | |
{ | |
disp.BeginInvoke(Original, new object[] { a, b }); | |
}); | |
} | |
public static Action<T1, T2, T3> Route<T1, T2, T3>(this Dispatcher disp, Action<T1, T2, T3> Original) | |
{ | |
return ((a, b, c) => | |
{ | |
disp.BeginInvoke(Original, new object[] { a, b, c}); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment