在启动下一个命令之前,我有三个命令要执行,等待每个命令完成。
根据我在完成第一个之后的实现,第二个将开始,但backgroundWorker1_RunWorkerCompleted根本不会加注。
npm install sqlite3
答案 0 :(得分:0)
BackgroundWorker只是一次性使用,即一旦状态完成它就不会重新启动,你需要重新实例化它。
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
command++;
if (command < commands.Length)
{
backgroundWorker1 = new BackgroundWorker();
backgroundWorker1.DoWork += this.backgroundWorker1_DoWork;
backgroundWorker1.ProgressChanged += this.backgroundWorker1_ProgressChanged;
backgroundWorker1.RunWorkerCompleted += this.backgroundWorker1_RunWorkerCompleted;
backgroundWorker1.RunWorkerAsync();
}
}