private void TaskStateChangingHandler(object sender, PropertyUpdateEventArgs <TaskState> e) { var er = new EventRecord(nameof(TestTask.StateChanging), sender, e); lock (EventRecords) { EventRecords.Add(er); } }
/// <inheritdoc /> public async Task PopulariseEvent(CancellationToken cancellationToken, Guid eventId, DateTime created) { if (!cancellationToken.IsCancellationRequested) { Logger.LogInformation("Popularising event {Id}", eventId); var popularityRecord = EventRecords.FirstOrDefault(x => x.Record == eventId); using var scope = ServiceProvider.CreateScope(); var context = scope.ServiceProvider.GetRequiredService <ApplicationContext>(); var e = await context.Events .Include(x => x.EventCategories) .AsNoTracking().AsSplitQuery() .FirstOrDefaultAsync(x => x.Id == eventId, cancellationToken); if (e == null) { Logger.LogInformation("Event not found"); return; } // if the event is already popular if (popularityRecord != null) { Logger.LogInformation("Event {Id} is already popular, making more popular", eventId); popularityRecord.Updated = created; popularityRecord.Score++; } else { EventRecords.Add(new PopularityRecord { Added = created, Updated = created, Record = eventId, Score = 1 }); } if (e.EventCategories.Any()) { foreach (var category in e.EventCategories) { await PopulariseCategory(cancellationToken, category.CategoryId, created); } } // sends popular events to all web-socket clients await PopularityHubContext.Clients.All.SendAsync("events", await GetPopularEvents()); Logger.LogInformation("Popularised event {Id}", eventId); } }
private void HandleRecordCollectionChanged(object sender, NotifyCollectionChangedEventArgs args) { // This method is multithreaded to demonstate the next marshalling stage for the UI update. // Synchronize it here to keep bad things from happening. lock (EventRecords) { if (args.NewItems != null) { foreach (var record in args.NewItems) { var recordVM = new RecordViewModel() { Model = record as HandlerRecord, DelegateInvokeThreadId = _invokerThreadId }; EventRecords.Add(recordVM); } } } }
public void Read(BinaryReader binaryReader) { EventRecords.Clear(); IsNull = binaryReader.ReadBoolean(); if (IsNull) { return; } else { var length = binaryReader.ReadInt32(); for (var i = 0; length > i; i++) { var eventRecord = new EventRecord(); eventRecord.Read(binaryReader); EventRecords.Add(eventRecord); } } }
public EventRecordArray AddEventRecord(EventRecord eventRecord) { EventRecords.Add(eventRecord); return(this); }
public ROCMaster_EventRecordArray AddEventRecord(ROCMaster_EventRecord eventRecord) { EventRecords.Add(eventRecord); return(this); }