Aspose.words multi-threading failure

Hi,


I am attempting to run multiple threads for creating documents in the hopes of getting a large number completed quicker.
It falls over when inserting a cell on the merge callback: docBuilder.InsertCell();
On trying I get the following error:

Cannot start a cell in this state.

This is from:{Aspose.Words.Tables.Cell ()}

at Aspose.Words.MailMerging.MailMerge. (FieldMergingArgs )
at . (FieldMergeField , FieldMergingArgs& )
at Aspose.Words.Fields.FieldMergeField. ( , MailMerge )
at Aspose.Words.Fields.FieldMergeField. ( )
at Aspose.Words.Fields.FieldMergeField.86q6acmbfp2kjwdcs2q6rs3uwmqt2zc9 ()
at ​ . (Field )
at ​ . (Field )
at ​ . ( ​ )
at ​ . ( ​ )
at ​ . ( ​ )
at ​ . ( )
at ​ . ( , )
at ​ . (ArrayList )
at . (ArrayList , ​ )
at . ()
at Aspose.Words.MailMerging.MailMerge. ( )
at Aspose.Words.MailMerging.MailMerge.Execute(DataTable table)

I cannot find any reference to this error.
So I had a basic function to perform the merge and just wrapped that in a loop to create a number of threads:

var tasks = new List<System.Threading.Tasks.Task>();
var take = 600;
var taken = 0;
var list = new ConcurrentBag<byte[]>();
while (taken < mergeData.Rows.Count)
{
var groupMergeData = mergeData.AsEnumerable().Skip(taken).Take(take).ToArray().CopyToDataTable();
System.Threading.Tasks.Task t = System.Threading.Tasks.Task.Run(() =>
{
list.Add(Merge(docTemplate, groupMergeData, format));
});
taken += groupMergeData.Rows.Count;
tasks.Add(t);
}

System.Threading.Tasks.Task.WaitAll(tasks.ToArray());

Should this be possible?

Sorted, the callback was being shared by all threads.

Hi there,

Thanks for your inquiry. To ensure a timely and accurate response, 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'll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.