Aspose.Slides for .NET: Support for Parallel Calls of Presentation.Save Method

Hi, I am trying to export the slides to HTML in parallel. However I get random exceptions in presentation.Save()
Could you please let me know how to accomplish this?

Presentation presentation = new Presentation();

ISlide firstSlide = presentation.Slides[0];
presentation.Slides.AddEmptySlide(firstSlide.LayoutSlide);
presentation.Slides.AddEmptySlide(firstSlide.LayoutSlide);
presentation.Slides.AddEmptySlide(firstSlide.LayoutSlide);
presentation.Slides.AddEmptySlide(firstSlide.LayoutSlide);
presentation.Slides.AddEmptySlide(firstSlide.LayoutSlide);
presentation.Slides.AddEmptySlide(firstSlide.LayoutSlide);
presentation.Slides.AddEmptySlide(firstSlide.LayoutSlide);
presentation.Slides.AddEmptySlide(firstSlide.LayoutSlide);
presentation.Slides.AddEmptySlide(firstSlide.LayoutSlide);

ConcurrentBag<string> slides = new ConcurrentBag<string>();

ResponsiveHtmlController controller = new ResponsiveHtmlController();
HtmlOptions htmlOptions = new HtmlOptions { HtmlFormatter = HtmlFormatter.CreateCustomFormatter(controller) };

Parallel.ForEach(presentation.Slides, (pptSlide) =>
{
    try
    {
        using (MemoryStream stream = new MemoryStream())
        {
            presentation.Save(stream, new[] { pptSlide.SlideNumber }, SaveFormat.Html, htmlOptions);

            stream.Position = 0;
            using (StreamReader reader = new StreamReader(stream))
            {
                var html = reader.ReadToEnd();
                slides.Add(html);
            }
        }
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.Print("SlideNumber: " + pptSlide.SlideNumber + " - " + ex.Message);
    }
});

These are the sample of the random exceptions:

Debug Trace:
SlideNumber: 8 - An item with the same key has already been added.
SlideNumber: 4 - An item with the same key has already been added.
SlideNumber: 5 - An item with the same key has already been added.
SlideNumber: 6 - Collection was modified; enumeration operation may not execute.
SlideNumber: 1 - Collection was modified; enumeration operation may not execute.
SlideNumber: 3 - An item with the same key has already been added.

@anarosa101,
Thank you for contacting support.

Unfortunately, Aspose.Slides does not support parallel processing for a single presentation instance. Such operations are not safe.

Documents: Multithreading in Aspose.Slides

Hi Andrey,
Thank you for the response. Is there any future plan to support parallel processing?
Ana

@anarosa101,
Unfortunately, there are no plans to support the parallel processing of PowerPoint presentations in Aspose.Slides yet.

We have linked the following appropriate ticket(s) in our internal issue tracking system to this forum thread and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): 
SLIDESNET-35724 (Investigate the possibility of multithreaded processing)

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thank you for your response

@anarosa101,
Thank you for using Aspose.Slides.