I'm processing a large excel (10k records) and it is a requirement that this process run on multiple threads to improve performance.
Right now i'm doing a check if row <= 2000 then that's fine run Utils.IxGenerateWithData with all records. But if row > 2000 (e.g. 10k) I want to split these into multiple threads that process Utils.IxGenerateWithData with 2000 records each.
Please help
using (Stream contentStream = await requestContent.ReadAsStreamAsync())
{
Workbook workbook = new Workbook(contentStream);
Worksheet worksheet = workbook.Worksheets[0];
int column = 0; // first column
Cell lastCell = worksheet.Cells.EndCellInColumn((short)column);
//Run on multiple threads if the file has more than 2000 records
if (lastCell.Row > 2000)
{
//Not sure what to do here
// Infiniti GenerateWithData Web Service
Thread thread = new Thread(() => Utils.IxGenerateWithData(payloadSettings.ProjectGUID, payloadSettings.DatasourceGUID, xmlContent, payloadSettings.InfinitiUsername, payloadSettings.InfinitiPassword, payloadSettings.ServiceWSDL));
thread.Start();
}
else
{
for (int row = 0; row <= lastCell.Row; row++)
{
Cell cell = worksheet.Cells.GetCell(row, column);
xmlContent += cell.StringValueWithoutFormat;
}
// Infiniti GenerateWithData Web Service
Utils.IxGenerateWithData(payloadSettings.ProjectGUID, payloadSettings.DatasourceGUID, xmlContent, payloadSettings.InfinitiUsername, payloadSettings.InfinitiPassword, payloadSettings.ServiceWSDL);
}
}