我创建了这样的代码来使用另一个类的 BackgroundWorker:
public void BackgroundWorkerTest()
{
BackgroundWorker bw = new BackgroundWorker();
bw.WorkerReportsProgress = true;
bw.WorkerSupportsCancellation = false;
bw.DoWork += new DoWorkEventHandler(DoWork);
bw.ProgressChanged += new ProgressChangedEventHandler(ProgressChanged);
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunWorkerCompleted);
bw.RunWorkerAsync();
while (bw.IsBusy)
System.Threading.Thread.Sleep(50);
}
private void DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
string connStr = "<conn_str>";
string path = "";
MyClass.StaticMethod(string1, string2, worker);
}
private void ProgressChanged(object sender, ProgressChangedEventArgs e)
{
int progress = e.ProgressPercentage;
string message = e.UserState.ToString();
}
private void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
string progress = "Done.";
}
从 MyClass.StaticMethod() 我打电话
worker.ReportProgress(percents, message);
发送进度信息。是否可以在 VBScript 中使用上述代码(在 BackgroundWorkerTest() 方法中提到)或类似代码?需要从 VBScript(在 InstallShield 中)输出进度信息。它有足够的能力吗?