private void ChangeStateThread(object p) { Monitor.Enter(ChangeStateSyncObject); var dispatcher = System.Windows.Deployment.Current.Dispatcher; if (WorkerStateChanged != null) { dispatcher.BeginInvoke(new Action(() => { var args = new WorkerStateEventArgs(); args.IsBusy = true; WorkerStateChanged(this, args); })); } var param = p as ChangeStateParam; InteropSvc.InteropLib.Instance.SetRadioState(param.deviceType, param.value, 0U); if (WorkerStateChanged != null) { dispatcher.BeginInvoke(new Action(() => { var args = new WorkerStateEventArgs(); args.IsBusy = false; WorkerStateChanged(this, args); })); } Monitor.Exit(ChangeStateSyncObject); }