Thread Safety
Posted: Tue Feb 22, 2011 1:29 am
Hello!
I am wondering if your methods are thread safe.
I have multiple threads which are creating and saving reports to the filesystem. The report template is always the same one - i always use "myreport.mrt" as template.
Sometimes i get strange exceptions when i load or compile the report. If I look into it, it seems that multiple threads are calling the Report.Load() or Report.Compile() methd at the same time. So my question is: Are these methods thread safe? There are service calls in these methods, are these services thread safe?
I hope you can help me on this.
I post the exceptions/stacktraces i got:
exception 1, when trying Report.Load(string path):
Mesage:
Unable to cast object of type 'System.String' to type 'Stimulsoft.Report.Dictionary.StiDataParameter'.
Stacktrace:
at Stimulsoft.Report.Dictionary.StiDataParametersCollection.OnInsert(Int32 index, Object value)
at System.Collections.CollectionBase.System.Collections.IList.Add(Object value)
at Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject(Object obj, StiPropertyInfoCollection props)
at Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject(Object obj, StiPropertyInfoCollection props)
at Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject(Object obj, StiPropertyInfoCollection props)
at Stimulsoft.Base.Serializing.StiSerializing.Deserialize(Object obj, Stream stream, String application)
at Stimulsoft.Report.SaveLoad.StiXmlReportSLService.Load(StiReport report, Stream stream)
at Stimulsoft.Report.StiReport.Load(StiReportSLService service, Stream stream)
at Stimulsoft.Report.StiReport.Load(Stream stream)
at Stimulsoft.Report.StiReport.Load(String path)
Exception 2, when trying to Report.Compile()
Message:
Collection was modified; enumeration operation may not execute.
Stacktrace:
at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext()
at Stimulsoft.Base.Services.StiServiceContainer.GetServices(Type serviceType, Boolean getEnabled, Boolean callBeforeGetService)
at Stimulsoft.Base.Services.StiServiceContainer.GetServices(Type serviceType, Boolean getEnabled)
at Stimulsoft.Base.Services.StiServiceContainer.GetServices(Type serviceType)
at Stimulsoft.Report.CodeDom.StiFunctionsParser.Parse(StiReport report, StiComponent ownerComponent, String& text, Boolean isScript, StiExpression expression, Boolean checkTotals)
at Stimulsoft.Report.CodeDom.StiCodeDomFunctions.ParseFunctionsInternal(Int32& functionIndex, StiCodeDomSerializator serializator, String propertyName, StiComponent comp, String& text, StiExpression expression, Boolean isScript)
at Stimulsoft.Report.CodeDom.StiCodeDomFunctions.ParseFunctions(StiCodeDomSerializator serializator, String propertyName, StiComponent comp, String& text, StiExpression expression, Boolean isScript)
at Stimulsoft.Report.CodeDom.StiCodeDomFunctions.ParseFunctions(StiCodeDomSerializator serializator, String propertyName, String text)
at Stimulsoft.Report.CodeDom.StiCodeDomFunctions.ParseFunctions(StiCodeDomSerializator serializator, String text)
at Stimulsoft.Report.CodeDom.StiCodeDomVariables.SerializeVariablesToCode(StiCodeDomSerializator serializator, StiReport report)
at Stimulsoft.Report.CodeDom.StiCodeDomVariables.Serialize(StiCodeDomSerializator serializator, StiReport report)
at Stimulsoft.Report.CodeDom.StiCodeDomSerializator.Serialize(StiReport report, String name, StiLanguage language, Boolean serializeData, Boolean saveForInheritedReports, Object standaloneReportType)
at Stimulsoft.Report.CodeDom.StiCodeDomSerializator.Serialize(StiReport report, String name, StiLanguage language, Object standaloneReportType)
at Stimulsoft.Report.StiReport.ScriptUpdate(Object standaloneReportType, Boolean allowUseResources)
at Stimulsoft.Report.StiReport.Compile(String path, Stream stream, StiOutputType outputType, Boolean autoCreate, Object standaloneReportType)
at Stimulsoft.Report.StiReport.Compile(String path, Stream stream, StiOutputType outputType, Boolean autoCreate)
at Stimulsoft.Report.StiReport.Compile(String path, StiOutputType outputType, Boolean autoCreate)
at Stimulsoft.Report.StiReport.Compile(String path, StiOutputType outputType)
at Stimulsoft.Report.StiReport.Compile(StiOutputType outputType)
at Stimulsoft.Report.StiReport.Compile()
best regards
joro
I am wondering if your methods are thread safe.
I have multiple threads which are creating and saving reports to the filesystem. The report template is always the same one - i always use "myreport.mrt" as template.
Sometimes i get strange exceptions when i load or compile the report. If I look into it, it seems that multiple threads are calling the Report.Load() or Report.Compile() methd at the same time. So my question is: Are these methods thread safe? There are service calls in these methods, are these services thread safe?
I hope you can help me on this.
I post the exceptions/stacktraces i got:
exception 1, when trying Report.Load(string path):
Mesage:
Unable to cast object of type 'System.String' to type 'Stimulsoft.Report.Dictionary.StiDataParameter'.
Stacktrace:
at Stimulsoft.Report.Dictionary.StiDataParametersCollection.OnInsert(Int32 index, Object value)
at System.Collections.CollectionBase.System.Collections.IList.Add(Object value)
at Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject(Object obj, StiPropertyInfoCollection props)
at Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject(Object obj, StiPropertyInfoCollection props)
at Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject(Object obj, StiPropertyInfoCollection props)
at Stimulsoft.Base.Serializing.StiSerializing.Deserialize(Object obj, Stream stream, String application)
at Stimulsoft.Report.SaveLoad.StiXmlReportSLService.Load(StiReport report, Stream stream)
at Stimulsoft.Report.StiReport.Load(StiReportSLService service, Stream stream)
at Stimulsoft.Report.StiReport.Load(Stream stream)
at Stimulsoft.Report.StiReport.Load(String path)
Exception 2, when trying to Report.Compile()
Message:
Collection was modified; enumeration operation may not execute.
Stacktrace:
at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext()
at Stimulsoft.Base.Services.StiServiceContainer.GetServices(Type serviceType, Boolean getEnabled, Boolean callBeforeGetService)
at Stimulsoft.Base.Services.StiServiceContainer.GetServices(Type serviceType, Boolean getEnabled)
at Stimulsoft.Base.Services.StiServiceContainer.GetServices(Type serviceType)
at Stimulsoft.Report.CodeDom.StiFunctionsParser.Parse(StiReport report, StiComponent ownerComponent, String& text, Boolean isScript, StiExpression expression, Boolean checkTotals)
at Stimulsoft.Report.CodeDom.StiCodeDomFunctions.ParseFunctionsInternal(Int32& functionIndex, StiCodeDomSerializator serializator, String propertyName, StiComponent comp, String& text, StiExpression expression, Boolean isScript)
at Stimulsoft.Report.CodeDom.StiCodeDomFunctions.ParseFunctions(StiCodeDomSerializator serializator, String propertyName, StiComponent comp, String& text, StiExpression expression, Boolean isScript)
at Stimulsoft.Report.CodeDom.StiCodeDomFunctions.ParseFunctions(StiCodeDomSerializator serializator, String propertyName, String text)
at Stimulsoft.Report.CodeDom.StiCodeDomFunctions.ParseFunctions(StiCodeDomSerializator serializator, String text)
at Stimulsoft.Report.CodeDom.StiCodeDomVariables.SerializeVariablesToCode(StiCodeDomSerializator serializator, StiReport report)
at Stimulsoft.Report.CodeDom.StiCodeDomVariables.Serialize(StiCodeDomSerializator serializator, StiReport report)
at Stimulsoft.Report.CodeDom.StiCodeDomSerializator.Serialize(StiReport report, String name, StiLanguage language, Boolean serializeData, Boolean saveForInheritedReports, Object standaloneReportType)
at Stimulsoft.Report.CodeDom.StiCodeDomSerializator.Serialize(StiReport report, String name, StiLanguage language, Object standaloneReportType)
at Stimulsoft.Report.StiReport.ScriptUpdate(Object standaloneReportType, Boolean allowUseResources)
at Stimulsoft.Report.StiReport.Compile(String path, Stream stream, StiOutputType outputType, Boolean autoCreate, Object standaloneReportType)
at Stimulsoft.Report.StiReport.Compile(String path, Stream stream, StiOutputType outputType, Boolean autoCreate)
at Stimulsoft.Report.StiReport.Compile(String path, StiOutputType outputType, Boolean autoCreate)
at Stimulsoft.Report.StiReport.Compile(String path, StiOutputType outputType)
at Stimulsoft.Report.StiReport.Compile(StiOutputType outputType)
at Stimulsoft.Report.StiReport.Compile()
best regards
joro