private void Bgworker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { BackgroundInformation q = e.Result as BackgroundInformation; if (q == null || !q.OutPassed) { _timerMenu.Enabled = false; MenuAnimation(true, true); } else if (q.OutPassed) { _info = q; if (q.OutUnreadCount == 0) { _timerMenu.Enabled = false; MenuAnimation(true); } else { if (!_timerMenu.Enabled) { _timerMenu.Enabled = true; } if (_info.FirstStart) { ShowFormNotification(); } } } _info.FirstStart = false; _timer.Enabled = true; }
public Looper(NotificationRepository repo) { _repo = repo; _timer = new Timer(); _timer.Interval = TimerIntervalSec * 1000; _timer.Tick += Timer_Tick; PluginInitialization._appEvent.PropertyChanged += _appEvent_PropertyChanged; AddMainMenu(); _info = new BackgroundInformation(); _info.FirstStart = true; _bgworker = new BackgroundWorker(); _bgworker.DoWork += Bgworker_DoWork; _bgworker.RunWorkerCompleted += Bgworker_RunWorkerCompleted; _timer.Enabled = true; _timerMenu = new Timer(); _timerMenu.Interval = 1000; _timerMenu.Tick += _timerMenu_Tick; }
private void Bgworker_DoWork(object sender, DoWorkEventArgs e) { BackgroundInformation myinfo = e.Argument as BackgroundInformation; if (myinfo == null) { return; } try { myinfo.OutUnreadCount = _repo.GetUnreadCount(); myinfo.OutPassed = true; } catch { myinfo.OutPassed = false; } e.Result = myinfo; }