We have the latest Aspose.Pdf 10.5 .NET and currently facing an issue where a few users “Click” generate PDF using the BindHTML gives random user of "System.InvalidOperationException: Object is currently in use elsewhere"
Hi Jeff,
It looks like this multiple thread issue is widespread in this forum.
Here’s our code snippet spawning 50 concurrent users:
class Program
{
static void Main(string[] args)
{
var lcn = new License();
lcn.SetLicense("Aspose.Pdf.lic");
for (int i = 0; i < 50; i++)
{
Thread thread = new Thread(new ThreadStart(WorkThreadFunction));
thread.Start();
}
Console.WriteLine("Hello!!!");
Console.ReadKey();
}
public static void WorkThreadFunction()
{
try
{
var htmlContent = "this is a link to a web site like [this](http://www.aspose.com/)";
Console.WriteLine("generate method");
String html = "this is a link to a web site like [this](http://www.aspose.com/)";
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
htmlLoadOptions.PageInfo.Margin.Bottom = 10;
htmlLoadOptions.PageInfo.Margin.Top = 20;
using (var memorystream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html)))
{
Document doc = new Document(memorystream, htmlLoadOptions);
doc.Save(Guid.NewGuid().ToString() + "output.pdf");
};
}
catch (Exception ex)
{
Console.WriteLine("WorkThreadFunction:: " + ex.Message);
}
}
}
Hi Jeff,
We found a not so great of fallback mechanism to RE-TRY rendering the Document if we get an exception.
Hi Jeff,