We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Does Aspose.Words for NET support multi-threading

I am appealing to the broader community to see if anyone has successfully built a multi-threaded application using the Aspose.Words .NET API to process multiple files in parallel? I am particularly interested in whether you see performance gains (or performance degradation) when you have plenty of available processing cores. Would anyone like to share some sample code? Would anyone like to share performance metrics? Thank you

@dgreenwood

Aspose.Words does support multi-threading. The only thing you need to make sure is that always use separate Document instance for each thread. One thread should use one Document object. You can use Parallel.ForEach as shown below to achieve your requirement.

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);
}