Beispiel #1
0
        StartFillQueue(
            string queueName,
            FillQueueCommandModel fillQueueCommand)
        {
            if (fillQueueCommand == null)
            {
                throw new ArgumentNullException(nameof(fillQueueCommand));
            }

            // Start the async task.
            this.FillQueue(queueName, fillQueueCommand.SizeMegabytes)
            .ConfigureAwait(false);

            FillOperations.AddOrUpdate(
                key:                queueName,
                addValueFactory:    name => new FillQueueStatusViewModel {
                Status = FillQueueStatus.Running
            },
                updateValueFactory: (name, fillOperation) => {
                if (fillOperation.Status != FillQueueStatus.Finished)
                {
                    throw new InvalidOperationException("A previous fill operation is still in progress.");
                }

                return(new FillQueueStatusViewModel {
                    Status = FillQueueStatus.Running
                });
            }

                );

            // Return while the task continues to run in the background.
        }
        StartFillQueue(
            string                queueName,
            FillQueueCommandModel fillQueueCommand)
        {
            if (fillQueueCommand == null)
                throw new ArgumentNullException(nameof(fillQueueCommand));

            // Start the async task.
            this.FillQueue(queueName, fillQueueCommand.SizeMegabytes)
                .ConfigureAwait(false);

            FillOperations.AddOrUpdate(
                key:                queueName,
                addValueFactory:    name => new FillQueueStatusViewModel { Status = FillQueueStatus.Running },
                updateValueFactory: (name, fillOperation) => {
                    if (fillOperation.Status != FillQueueStatus.Finished)
                        throw new InvalidOperationException("A previous fill operation is still in progress.");

                    return new FillQueueStatusViewModel { Status = FillQueueStatus.Running };
                }

            );

            // Return while the task continues to run in the background.
        }