I have such problem : there is some method
private List<int> GetStatusList()
{
return (List<int>)GetValue(getSpecifiedDebtStatusesProperty);
}
To invoke it in main thread - I use
`delegate List<int> ReturnStatusHandler();` ...
this.Dispatcher.Invoke(new ReturnStatusHandler(GetStatusList));
How can I do the same, using lambda expression instead of custom delegate and method?
you can pass this:
new Action(GetStatusList)
or
(Action)(() => { GetStatusList; })
You can avoid explicit casting by creating a simple method:
void RunInUiThread(Action action)
{
Dispatcher.Invoke(action);
}
Use this as follows:
RunInUiThread(() =>
{
GetStatusList();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With