2 comments

  1. var producers = Enumerable.Range(0, maxRequest)
    .Select(_ => Task.Run(() =>
    {
    foreach (var tfDocument in tfDocumentToBlockingCollection.GetConsumingEnumerable())
    {
    var objectSpaceRebuilt = objectSpace.Rebuild(tfDocument, true, false, false);

    queue.Add(objectSpaceRebuilt);

    perrysMenu.Percentage += resultPorcentage + resultPorcentage;
    }
    })).ToArray();

    var consume = Task.Run(() =>
    {
    foreach (var objectSpaceQueue in queue.GetConsumingEnumerable())
    {
    SendExportationRequest(objectSpaceQueue);
    }
    });

    The code above, I have a question. how can I consume many ” var consume” in that example? I mean, I used in produce a Range(0, maxRequest), but I would like to know how can I do the same in consuming.

    1. You can simply create more tasks. Take a look at the ProcessDocumentsUsingPipelinePattern method for an example.

Leave a Reply

Your email address will not be published. Required fields are marked *