private void _monitoringDataService_AlarmDataUpdated(object sender, AlarmDataEventArgs e) { var alarmStr = e.Data as string; if (!string.IsNullOrEmpty(alarmStr)) { var alarmInfo = JsonConvert.DeserializeObject <AlarmInfo>(alarmStr); if (alarmInfo != null) { var action = new Action(() => { _soundPlayer = new System.Media.SoundPlayer(); _soundPlayer.SoundLocation = Alarm_Sound_FilePath; _soundPlayer.PlayLooping(); }); action.BeginInvoke(null, null); System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { if (AlarmList.Count > ALARM_LIST_MAX_COUNT) { AlarmList.RemoveAt(AlarmList.Count - 1); } AlarmList.Add(alarmInfo); CurrentAlarmInfo = alarmInfo; IsShow = true; NotifiyAlarm(); })); } } }
private void _monitoringDataService_AlarmDataUpdated(object sender, AlarmDataEventArgs e) { var alarmStr = e.Data as string; if (!string.IsNullOrEmpty(alarmStr)) { var alarmInfo = JsonConvert.DeserializeObject <AlarmInfo>(alarmStr); if (alarmInfo != null) { System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(() => { if (!string.IsNullOrEmpty(CustomerId) && CustomerId == alarmInfo.CustomerId.ToString()) { HasAlarm = true; AlarmLevel = alarmInfo.Level; } })); } } }