Exemplo n.º 1
0
        private async Task PopulateSegment(ModuleData data, AnnotatedContainer annotatedContainer, CancellationToken token)
        {
            var timerToken     = new CancellationTokenSource(TimeSpan.FromSeconds(1)).Token;
            var effectiveToken = CancellationTokenSource.CreateLinkedTokenSource(token, timerToken).Token;

            try
            {
                var segment = await client.RequestDataAsync(annotatedContainer.Context.Address.Value, annotatedContainer.Container.Size, effectiveToken);

                data.Populate(annotatedContainer.Context.Address, segment);
            }
            catch (OperationCanceledException) when(timerToken.IsCancellationRequested)
            {
                logger.Log($"Device didn't respond for container {annotatedContainer.Path}; skipping.");
            }
            catch
            {
                logger.Log($"Failure while loading {annotatedContainer.Path}");
                throw;
            }
        }
Exemplo n.º 2
0
        private static async Task PopulateSegment(RolandMidiClient client, ModuleData data, AnnotatedContainer annotatedContainer, CancellationToken token, IStandardStreamWriter console)
        {
            var timerToken     = new CancellationTokenSource(TimeSpan.FromSeconds(1)).Token;
            var effectiveToken = CancellationTokenSource.CreateLinkedTokenSource(token, timerToken).Token;

            try
            {
                var segment = await client.RequestDataAsync(annotatedContainer.Context.Address.Value, annotatedContainer.Container.Size, effectiveToken);

                data.Populate(annotatedContainer.Context.Address, segment);
            }
            catch (OperationCanceledException) when(timerToken.IsCancellationRequested)
            {
                console.WriteLine($"Device didn't respond for container {annotatedContainer.Path}; skipping.");
            }
        }