Previously I had
Dispatcher.Invoke(new Action(() => colorManager.Update()));
to update display to WPF from another thread. Due to design
If you call Invoke
with an Action<T1, T2>
delegate, you need to pass the two Action parameters to the Invoke call:
ColorStreamManager colorManager = ...
ColorImageFrame frame = ...
Dispatcher.Invoke(
new Action<ColorStreamManager, ColorImageFrame>((p,v) => p.Update(v)),
colorManager,
frame);
The Invoke overload you're using here is Dispatcher.Invoke(Delegate, Object[]).
You don't want the action to have parameters, because the Dispatcher
isn't going to know what to pass to the method. Instead what you can do is close over the variable:
ColorImageFrame someFrame = ...;
Dispatcher.Invoke(new Action(() => colorManager.Update(someFrame)));