I want to execute this code on main thread in WPF app and getting error I can\'t figure out what is wrong:
private void AddLog(string logItem) {
You can also use MethodInvoker for this:
private void AddLog(string logItem) { this.Dispatcher.BeginInvoke((MethodInvoker) delegate { this.Log.Add(new KeyValuePair(DateTime.Now.ToLongTimeString(), logItem)); }); }