EPPlus icon indicating copy to clipboard operation
EPPlus copied to clipboard

Multiple threading operations on different worksheets can easily cause exceptions

Open iray1024 opened this issue 1 year ago • 2 comments

The following code will be executed in a multi-threaded environment, even if it operates on different worksheets, it may still throw exceptions, similar to inserting existing keys in a dictionary.

Example: lock (_syncRoot) { workSheet = param.Package.Workbook.Worksheets.Add(param.ExportMetadata.Definition.WorkSheetName); }

Load(workSheet, param.ExportMetadata);

param.ExportMetadata.Definition.AdjustStyle(workSheet);

iray1024 avatar Jun 06 '23 02:06 iray1024

No, avoid using multiple threads on a single workbook. We will look into better multithreading support in coming versions.

JanKallman avatar Jun 06 '23 07:06 JanKallman

Hi guys.

I'm using your EpPlus and encountered errors in multithreading. Is it possible to clarify what kind of work you are doing to improve stability? Thanks

P.S. Are there any effective methods that will help avoid problems with multithreading in current versions?

happydaf avatar Feb 20 '24 10:02 happydaf