public async Task Activate() { await Deactivate(); try { await _syncer.WaitAsync(); UnreadedStream = new NotificationStream(_account.PlusClient.Notification.GetNotifications(true), _account); ReadedStream = new NotificationStream(_account.PlusClient.Notification.GetNotifications(false), _account); _timer = Observable.Timer(DateTimeOffset.MinValue, TimeSpan.FromMinutes(5)) .Subscribe(async obj => await Connect().ConfigureAwait(false)); } finally { _syncer.Release(); } }
public async Task Deactivate() { try { await _syncer.WaitAsync(); if (_timer != null) { _timer.Dispose(); _timer = null; } if (_notificationTrigger != null) { _notificationTrigger.Dispose(); _notificationTrigger = null; } UnreadedStream = null; ReadedStream = null; } finally { _syncer.Release(); } }
public NotificationStreamViewModel(string name, NotificationStream model) { _name = name; _streamModel = model; Items = new ObservableCollection<NotificationViewModel>(); model.ChangedStatus += model_ChangedStatus; model.Items.CollectionChanged += Items_CollectionChanged; PropertyChanged += NotificationManagerViewModel_PropertyChanged; }