큰 엑셀 (10k 레코드)을 처리하고 있으며이 프로세스를 성능을 향상 시키려면 여러 스레드에서 실행해야합니다.분할하는 방법 행을 여러 개의 동일한 로트와 반복 처리하는 방법
지금은 행 < = 2000이면 확인하고 있는데, Utils.IxGenerateWithData를 모든 레코드와 함께 실행하면 문제가 없습니다. 그러나 행> 2000 (예 : 10k) 인 경우이를 Utils.IxGenerateWithData를 처리하는 여러 스레드로 분할하여 각각 2000 개의 레코드로 만듭니다.
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);
}
}
나는 당신을 도울 수 있는지 모르겠지만 왜 "수익률"을 사용하지 않습니까? http://www.ytechie.com/2009/02/using-c-yield-for-readability-and-performance/ –