private void _connectionReceive_StatisticsUpdated(object sender, StatisticsEventArgs e) { App.Current.Dispatcher.Invoke((Action)(() => { StatisticsUpdated?.Invoke(sender, e); })); }
void IHandle <StatisticsUpdated> .Handle(StatisticsUpdated message) { if (!message.HasDocumentCountChanged) { return; } RetrieveSummary(); }
private void Status(Cache cache) { if ((DateTime.UtcNow - _lastStatusCheck).TotalMilliseconds < Settings.Instance.StatusInterval) { return; } _lastStatusCheck = DateTime.UtcNow; // Сообщим всем наши данные var contactSelf = new Contact() { ID = Settings.Instance.PublicKey, Name = Settings.Instance.Name, Version = Settings.Version, LastOnline = _lastStatusCheck, RequireEncryption = Settings.Instance.RequireEncryption }; byte[] profileBytes = Helpers.SerializeToStream(contactSelf).ToArray(); DateTime start = DateTime.Now; cache.Set("#PROFILE#" + contactSelf.ID, profileBytes, Settings.Instance.LifetimeInterval, TIMEOUT); double lag = (DateTime.Now - start).TotalMilliseconds; // Соберем профили всех пользователей онлайн var contacts = new List <Contact>(); var profiles = cache.BatchGet("#PROFILE#", TIMEOUT); if (profiles != null) { foreach (var profile in profiles) { if (profile.Value == null) { continue; } using (var ms = new MemoryStream(profile.Value)) contacts.Add((Contact)Helpers.DeserializeFromStream(ms)); } } ContactsUpdated?.Invoke(this, new ContactsUpdatedEventArgs(contacts.ToArray())); StatisticsUpdated?.Invoke(this, new StatisticsEventArgs(lag)); }
/// <summary> /// Invokes the <see cref="StatisticsUpdated"/> event asynchronously. (Can be override /// for event catching) /// </summary> /// <param name="eventArgs">the event arguments</param> /// <returns>a task that represents the asynchronous operation</returns> protected virtual Task OnStatisticsUpdateAsync(NodeStatisticsUpdateEventArgs eventArgs) => StatisticsUpdated.InvokeAsync(this, eventArgs);
/// <summary> /// Fires the statistics updated event. /// </summary> protected virtual void OnStatisticsUpdated() { StatisticsUpdated?.Invoke(this, new StatisticalEventArgs(_scheme.Statistics)); }
protected virtual void OnStatisticsUpdated(StatisticOperation operation, Statistic stat) { ReloadStatistics(operation, stat); StatisticsUpdated?.Invoke(this, new StatisticsUpdatedEventArgs(operation, stat)); }