Given this code....
public class CalibrationViewModel : ViewModelBase
{
private FileSystemWatcher fsw;
public CalibrationViewModel(Calibration calibrati
It's because Dispatcher is a class not a property. Shouldn't you be making your CalibrationViewModel class a subclass of some other class which has a Dispatcher property?
Change this:
Dispatcher.BeginInvoke
to this:
Dispatcher.CurrentDispatcher.BeginInvoke
the issue is BeginInvoke is an instance method and needs an instance to access it. However, your current syntax is trying to access BeginInvoke in a static manner off the class Dispatcher and that's what's causing this error:
Cannot access non-static method BeginInvoke in static context
If this is WPF, System.Windows.Threading.Dispatcher does not have a static BeginInvoke() method.
If you want to call that statically (this is, without having a reference to the Dispatcher instance itself), you may use the static Dispatcher.CurrentDispatcher property:
Dispatcher.CurrentDispatcher.BeginInvoke(...etc);
Be aware though, that doing this from a background thread will NOT return a reference to the "UI Thread"'s Dispatcher, but instead create a NEW Dispatcher instance associated with the said Background Thread.
A more secure way to access the "UI Thread"'s Dispatcher is via the use of the System.Windows.Application.Current static property:
Application.Current.Dispatcher.BeginInvoke(...etc);