1

Consider the following code.

using System.Threading.Tasks;
using System.Collections.Generic;
using HiQPdf;

namespace bla 
{
    class Program 
    {
        private static List<Task> tlist = new List<Task>();

        static void Main(string[] args) 
        {
            for (int i = 0; i < 21; i++) 
            {
                tlist.Add(Task.Run(() => 
                {
                    var r = new HtmlToPdf();
                    var pdf = r.ConvertUrlToMemory("google.com");
                }));
            }
            Task.WaitAll(tlist.ToArray());
        }
    }
}

This creates 20 instances of HiQPDF which creates an image of google. Thing is, HiQPDF creates an instance of HiQPDF.dep and HiQPDF.rda, which do the actual work. The maximum number of parallel HiQPDF processes seems to be 4. This is quite a long process and is critical for what I want to do.

What I want is increasing the limit of 4 concurrent processes.

I tried using Parallel.ForEach() and .AsParallel().ForAll(), different implementations of Threading but nothing helps with increasing the actual number of processes that run in parallel. I'm starting to think this is a limitation of Windows 10.

maccettura
  • 10,514
  • 3
  • 28
  • 35
Punishbear
  • 13
  • 3
  • Possible duplicate of [How to limit the Maximum number of parallel tasks in c#](https://stackoverflow.com/questions/36564596/how-to-limit-the-maximum-number-of-parallel-tasks-in-c-sharp) – Deblaton Jean-Philippe May 25 '18 at 15:35
  • What symptoms do you have to think the maximum # is 4? – NetMage May 25 '18 at 21:20
  • Have you look at the default value of [`MaxParallelConversions`](http://www.hiqpdf.com/documentation/html/F_HiQPdf_HtmlToPdf_MaxParallelConversions.htm) ? – NetMage May 25 '18 at 21:22

1 Answers1

1

A quick check in the library shows the default for HtmlToPdf.MaxParallelConversions is 4. I think you should increase it:

HtmlToPdf.MaxParallelConversions = 20;
NetMage
  • 26,163
  • 3
  • 34
  • 55