How to use Aspose.Words in multithreading

What did you find to be the best solution for this?

What was the best solution for this?

@brett5d90e

You can use Parallel.ForEach loop as shown below for multithreading. Hope this helps you.

string testFilesDirectory = Directory.GetCurrentDirectory() + "\\Test_Files";
string[] files = Directory.GetFiles(testFilesDirectory);

try
{
    Parallel.ForEach(files, file =>
    {
        Aspose.Words.LoadOptions options = new Aspose.Words.LoadOptions();
        options.LoadFormat = LoadFormat.Mhtml;
        Document doc = new Document(file, options);
        Console.WriteLine("Successfully opened " + file);
        doc.Save(file + ".pdf");
    });

}
catch (Exception ex)
{
    Console.WriteLine(ex.Message);
}