2

实际上,我需要提示加载图像throwugh backgrounderworker,每当调用特定函数时,这里就是我的代码:

 private void bgwFile_DoWork(object sender, DoWorkEventArgs e)
 {
        FormFieldsLoad();      
 }

private void bgwFile_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
    if (e.Cancelled == true)
    {
        Status.Text = "cancelled";
    }
    else if (e.Error != null)
    {
    }

    picprocess.SendToBack(); 
    Status.Text = "Completed";         
}

 //Below Method where i have called RunWorkerAsync()
private void buttonUpload_Click(object sender, EventArgs e)
{
    LoadFile(pdfFullPath, txtPassword.Text);
    form = document.getDocumentCatalog().getAcroForm();
    java.util.List FieldTypes = form.getFields();
    availableFieldsTable.Clear();
    btnLoad.Enabled = false;     
    Status.Text = "Document loaded successfully!!!";

    picprocess.BringToFront();  
    bgwFile.RunWorkerAsync();
}

在运行上述代码时,它调用加载图像但没有显示输出它继续显示加载图像..它没有调用 RunWorkerCompleted

任何人都可以帮助我吗?

谢谢

4

3 回答 3

3

您是否分配了事件处理程序?

bwgFile.DoWork += bgwFile_DoWork;
bwgFile.RunWorkerCompleted += bgwFile_RunWorkerCompleted;

你确定FormFieldsLoad终止?

于 2013-03-29T12:28:09.337 回答
0

As @Rik said, have you assigned the event handler?

If you have, put a break point or other trace to verify that your bgwFile_DoWork method execute as you expect and aren't getting stuck in an infinite loop or something.

于 2013-03-29T13:07:29.837 回答
0

DoWork 真的完成了吗?此代码会在输出窗口中打印任何内容吗?

 private void bgwFile_DoWork(object sender, DoWorkEventArgs e)
 {
        FormFieldsLoad();      
        Console.WriteLine("Work done");
 } // <-or put a breakpoint here
于 2013-03-29T13:47:06.960 回答