0
데이터 테이블 행로드를 반복하고 PDF가 아직없는 경우 생성하려면 다음 코드를 작성했습니다. 작동하지만 wkhtmltoPDF를 한 번에 실행하므로 30 개의 프로세스가 시작되어 서버가 종료됩니다.시스템 프로세스 시작을 대기열에 넣는 방법
한 번에 하나의 프로세스를 시작하고 이전 프로세스가 실행될 때까지 두 번째 프로세스를 시작하는 가장 좋은 방법은 무엇입니까?
DB db = new DB();
DataTable dtPosters = db.GetDataTable("select * from Invoices where PDFGenerated <> 1 or PDFGenerated is Null");
foreach (DataRow DR in dtPosters.Rows)
{
//Generate Poster, If exsists (Don't!)
Directory.CreateDirectory(string.Format("D:\\Invoices\\"));
string FilePath = string.Format("D:\\Invoices\\{0}.pdf", DR["InvoiceNumber"].ToString());
if (!File.Exists(FilePath))
{
string CMD = string.Format("C:\\Services\\Automafe\\wkhtmltoPDF.exe http://invoicegen/viewinvoice.aspx?InvoiceNumber={0} {1}", DR["InvoiceNumber"].ToString(), FilePath);
System.Diagnostics.Process.Start("cmd", "/c " + CMD);
}
else
{
//Update the DB
}
}
당신은 프로세스가 아니라 여기에, 닫힐 때 볼 이벤트 리스너를 추가 할 수 있습니다 http://stackoverflow.com/a/8455896/575530 – dumbledad
이 하나의 더 나은'process.WaitForExit()'HTTP : //stackoverflow.com/a/3147920/575530 – dumbledad