public void clear(MainWindow con, ListView lv) { if (!lv.CheckAccess()) { con.Dispatcher.Invoke(DispatcherPriority.Send, (Action)delegate { lv.Items.Clear(); }); } else { lv.Items.Clear(); } }