Perform n mongodb updates at a time using SemaphoreSlim I have a queue of jobs, and I want to process 20 at a time using asynchronous concurrency. 

When processing a job, some updates in MongoDb are made an a file gets uploaded to a server, that's up to 1GB and would take about 40 seconds.

What do you think?

Program.cs

 public static void Main(string[] args)
{
    MainAsync(args).Wait();
}

 public static async Task MainAsync(string[] args)
    {
        var serviceCollection = new ServiceCollection();
        ConfigureServices(serviceCollection);

        var serviceProvider = serviceCollection
            .AddLogging()
            .AddAutoMapper(typeof(Program))
            .BuildServiceProvider();

        await serviceProvider.GetService&lt;App&gt;().Run(20);
    }


App.cs  

public class App
{
    private readonly IQueueService _queueService;
    private readonly IUploadService _uploadService;
    private SemaphoreSlim _throttle;

    public App(IQueueService queueService, IUploadService uploadService)
    {
        _queueService = queueService;
        _uploadService = uploadService;
    }

    public async Task Run(int initialCount = 3)
    {
        _throttle = new SemaphoreSlim(initialCount);

        var jobs = await _queueService.GetQueue();

        var tasks = jobs.Select(ProcessJob);
        await Task.WhenAll(tasks);

        Console.WriteLine("Upload finished...");
        Console.ReadKey();
    }

    private async Task ProcessJob(JobDto JobDto)
    {
        await _throttle.WaitAsync();
        try
        {
            // Process file
            Guid.TryParse(JobDto.JobName, out var jobId);
            var isUploaded = await _uploadService.Upload(JobDto.CreatedBy, jobId);

            // Update collection
            await _queueService.DeleteJobQueue(JobDto.Id);
        }
        finally
        {
            _throttle.Release();
        }
    }
}
I see two issues with the provided code:


You are using a queue, however I only see a single call to retrieve items from the queue, when you start the application. Does this mean all the jobs are there when Run() is called?
You want to process 20 jobs at a time, but can _uploadService.Upload actually handle unlimited simultaneous requests? Or does it silently peak at something like 2 * number of cores or the size of the thread pool?