Is there any way to dispatch all methods in class in easy way?
For example my class is a adapter for UI items and contains static methods. So instead of dispatching all methods separately in class, it could be done like this: Who ever is calling a method from this class, everything is dispatched through UI thread.
Like from:
public MyClass
{
...
public static void Method1
{
Application.Current.Dispatcher.Invoke(() =>
{
/* do something */
}
}
public static bool Method2
{
return Application.Current.Dispatcher.Invoke(() =>
{
return UIitem.SomeProperty;
}
}
}
To this:
[DispatcherAttribute] /* or something similar */
public MyClass
{
...
public static void Method1
{
/* do something */
}
public static bool Method2
{
return UIitem.SomeProperty;
}
}