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

Free Support Forum - aspose.com

Bug report: Aspose.words.dll seems not to support multiple threads

Hi, support,

The aspose.words.dll seems not to support multiple threads. Why?
When I try to run it under multiple threads on VB.Net, it output nothing, or throws exception such as illegal character in path when reading source file except for the first file.

What’s wrong?

Thanks for your attention.

Ducaisoft

@ducaisoft

Thanks for your inquiry. Aspose.Words is multi thread safe as long as only one thread works on a document at a time. It is a typical scenario to have one thread working on one document. Different threads can safely work on different documents at the same time. Moreover, the Document objects are independent of each other and as long as only one thread at a time is allowed to modify a document.

Thanks for your reply.
But I wonder to know how to let it work under multi threads or copies. My Codes like this:

Step 1: Build a Command Line EXE application based on VB.net and aspose.words.dll, whose exe application name is called DocBackDo.exe
Step 2 : Build a main EXE application that will be used to call the DocBackDo.exe in multi threads mode like this:
For pi as long =0 to Listbox1.items.count-1
for I as long=1 to 5 'five multi copies run at a time
sFile=Listbox1.items(pi)
dFile=Outpath & “” & Pi & “.doc”
shellexecute 0,“open”,“DocBackDo.exe”,sFile & vbtab & dFile & vbtab & CmdLineParams,0
pi=pi+1
Application.DoEvents
Next
Application.DoEvents
next
However, they output nothing. By debugging the source code of DocBackDo.exe, it will be found that the code doc=new aspose.words.document(sFile) has gotten nothing and throws an exception as “5 illegal character in path”.
If code like this:
For pi as long =0 to Listbox1.items.count-1
sFile=Listbox1.items(pi)
dFile=Outpath & “” & Pi & “.doc”
WordHandle sFile,dFile, HandleParams
Application.DoEvents
next
this will work and desired output is met.

what’s wrong between them and what happen for this issue? How to let it work under multi threads or run-copies?


@ducaisoft

Thanks for your inquiry.

The only thing you need to make sure is that you always use separate Document instances per each thread. One thread should use one Document object.

Your issue is more related to path of document instead of multi threading. If you are facing issue with Aspose.Words, please attach the following resources here for testing:

  • Your input Word documents.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.