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

Free Support Forum - aspose.com

MultiThread problem with DocX Aspose.Words.saveAsPdf (6.0.0.0 .NET)

I test Aspose.Words Docx to Pdf conversion with 2 threads.

The result is an error :

Exception non gérée :Exception non gérée : System.InvalidOperationException: L'objet est actuellement utilisé ailleurs.
à System.Drawing.Graphics.MeasureString(String text, Font font, PointF origin, StringFormat stringFormat)
à ?.?.?(Graphics ?, String ?, Font ?)
à ?.?.?(String ?, Font ?)
à ?.?.?(String ?, ? ?)
à ?.?.get_Size()
à ?.?.?(? ?)
à ?.?.?(? ?)
à ?.?.VisitGlyphs(? glyphs)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à Aspose.Words.Document.SaveToPdf(Int32 pageIndex, Int32 pageCount, Stream stream, PdfOptions options)
à Aspose.Words.Document.?(Stream ?, String ?, SaveFormat ?)
à Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)
à Aspose.Words.Document.Save(String fileName)
à MyconsoleApp.Program.WorkerThreadMethod1() dans D:\_Aspose\Test_Csharp\MyconsoleAppTHread\MyconsoleApp\Program.cs:ligne 22
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()System.InvalidOperationException: L'objet est actuellement utilisé ailleurs.
à System.Drawing.Graphics.MeasureString(String text, Font font, PointF origin, StringFormat stringFormat)
à ?.?.?(Graphics ?, String ?, Font ?)
à ?.?.?(String ?, Font ?)
à ?.?.?(String ?, ? ?)
à ?.?.get_Size()
à ?.?.?(? ?)
à ?.?.?(? ?)
à ?.?.VisitGlyphs(? glyphs)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à ?.?.Accept(? visitor)
à Aspose.Words.Document.SaveToPdf(Int32 pageIndex, Int32 pageCount, Stream stream, PdfOptions options)
à Aspose.Words.Document.?(Stream ?, String ?, SaveFormat ?)
à Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)
à Aspose.Words.Document.Save(String fileName)
à MyconsoleApp.Program.WorkerThreadMethod2() dans D:\_Aspose\Test_Csharp\MyconsoleAppTHread\MyconsoleApp\Program.cs:ligne 33
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()

Here is my C# code :

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using Aspose.Words;

namespace MyconsoleApp
{
class Program
{
public static void WorkerThreadMethod1()
{
string fileNameDocX = "Test.1.docx";
string fileNamePdf = "Test.1.pdf";
Console.WriteLine("Debut_1 " + fileNameDocX );
Aspose.Words.Document mDocument;
mDocument = new Aspose.Words.Document(fileNameDocX);
mDocument.Save(fileNamePdf);
Console.WriteLine("Fin_1 " + fileNameDocX );
}

public static void WorkerThreadMethod2()
{
string fileNameDocX = "Test.2.docx";
string fileNamePdf = "Test.2.pdf";
Console.WriteLine("Debut_2 " + fileNameDocX );
Aspose.Words.Document mDocument;
mDocument = new Aspose.Words.Document(fileNameDocX);
mDocument.Save(fileNamePdf);
Console.WriteLine("Fin_2 " + fileNameDocX );
}

static void Main(string[] args)
{

Aspose.Words.License license = new Aspose.Words.License();
license.SetLicense("Aspose.Words.lic");

ThreadStart worker1 = new ThreadStart(WorkerThreadMethod1);
ThreadStart worker2 = new ThreadStart(WorkerThreadMethod2);

Console.WriteLine("Main - Creating worker threads");

Thread t1 = new Thread(worker1);
Thread t2 = new Thread(worker2);

t1.Start();
t2.Start();

while(t1.IsAlive)
{
Thread.Sleep(1000);
}

while (t2.IsAlive)
{
Thread.Sleep(1000);
}
}
}
}

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I managed to reproduce the problem on my side and created new issue #6912 in our defect database. I will notify you as soon as it is fixed.

Best regards.

The issues you have found earlier (filed as 6912) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by alexey.noskov.

Thanks. MultiThreading works now.