Is Aspose.Excel thread safe?
We have a web application that spawns threads and each thread generates an Excel file.
Excel files generated from the threads look OK, except they have the evaluation message worksheet, even with a correct license file.
Excel files generated without threading work perfectly, as expected. Both methods use the same license file.
Here is some code that reproduces the problem, an ASP.NET app with two buttons, one button to use threading, one to not use threading:
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
LicenseTest licenseTest = new LicenseTest();
ThreadStart start = new ThreadStart(licenseTest.RunTest);
Thread StatementThread = new Thread(start);
StatementThread.Start();
}
private void Button2_Click(object sender, System.EventArgs e)
{
LicenseTest licenseTest = new LicenseTest();
licenseTest.RunTest();
}
}
public class LicenseTest
{
protected Excel m_XLSStatement;
public LicenseTest()
{
}
public void RunTest()
{
string LicensePath = “c:\Aspose.Excel.lic”;
StreamReader licenseStream = new StreamReader(LicensePath, UnicodeEncoding.UTF7);
m_XLSStatement = new Excel(licenseStream);
m_XLSStatement.Save(“c:\TMP\ABTest.xls”, Aspose.Excel.FileFormatType.Default);
}
}