Beispiel #1
0
        public void OnReagentUpdated(ReagentUpdate update)
        {
            _logger.LogReceived($"{update}");

            // Map to other representation (Note: We have deliberately not used the same type here)
            ReagentItem updateToClients = new ReagentItem
            {
                Serial      = update.Serial,
                Location    = update.Location,
                ProductName = update.ProductName,
                Quantity    = update.Quantity
            };

            foreach (var client in _clients)
            {
                try
                {
                    client.ReagentItemUpdated(updateToClients);
                }
                catch (Exception exception)
                {
                    _logger.LogError(exception);
                }
            }
        }
Beispiel #2
0
        public async Task OnReagentUpdatedAsync(ReagentUpdate update)
        {
            _logger.LogReceived($"{update}");

            // Map to other representation (Note: We have deliberately not used the same type here)
            ReagentItem updateToClients = new ReagentItem
            {
                Serial      = update.Serial,
                Location    = update.Location,
                ProductName = update.ProductName,
                Quantity    = update.Quantity
            };

            Task[] callbackTasks = null;
            lock (_syncClients)
            {
                callbackTasks = _clients
                                .Select(client => client.ReagentItemUpdatedAsync(updateToClients))
                                .ToArray()
                ;
            }

            try
            {
                await Task.WhenAll(callbackTasks).ConfigureAwait(false);
            }
            catch (ObjectDisposedException) {}
            catch (Exception exception)
            {
                _logger.LogError(exception);
            }
        }
Beispiel #3
0
        public async Task OnReagentUpdatedAsync(ReagentUpdate update)
        {
            _logger.LogReceived($"{update}");

            // Map to other representation (Note: We have deliberately not used the same type here)
            ReagentItem updateToClients = new ReagentItem
            {
                Serial      = update.Serial,
                Location    = update.Location,
                ProductName = update.ProductName,
                Quantity    = update.Quantity
            };

            Task compoundCallbackTask = null;

            lock (_syncClients)
            {
                compoundCallbackTask = Task.WhenAll(
                    _clients
                    .Select(client => client.ReagentItemUpdatedAsync(updateToClients))
                    .ToArray()
                    )
                ;
            }

            try
            {
                await compoundCallbackTask.ConfigureAwait(false); // <-- Due to await this only throws

                // the FIRST exception - not an AggregateException
                // containing all...
            }
            catch
            {
                // ... but the compoundCallbackTask.Exception is exactly that AggregateException!
                AggregateException compoundException = compoundCallbackTask.Exception.Flatten();
                foreach (Exception exception in compoundException.InnerExceptions)
                {
                    if (exception is ObjectDisposedException)
                    {
                        // Silently ignore
                    }
                    else
                    {
                        _logger.LogError(exception);
                    }
                }
            }
        }
Beispiel #4
0
 public void Update(ReagentUpdate update) => Channel.Update(update);
 public void Update(ReagentUpdate update)
 {
     _serviceMediator.OnReagentUpdated(update);
 }
 public Task UpdateAsync(ReagentUpdate update) => _serviceMediator.OnReagentUpdatedAsync(update);
Beispiel #7
0
 public Task UpdateAsync(ReagentUpdate update) => Channel.UpdateAsync(update);