Cannot access non-static method in static context?

前端 未结 3 2035
春和景丽
春和景丽 2021-02-04 17:02

Given this code....

public class CalibrationViewModel : ViewModelBase
{
    private FileSystemWatcher fsw;

    public CalibrationViewModel(Calibration calibrati         


        
3条回答
  •  长情又很酷
    2021-02-04 17:31

    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

提交回复
热议问题