locked
backgrounworker RRS feed

  • Question

  • I inserted a backgroundworker form in my project.

    My intention is to execute a long time evaluation without blocking the graphic interface.

    These 2 routines should do the job:

    Public Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted

    End Sub

    Public Sub BackgroundWorker1_DoWork(sender As Object, e As ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
             x=math_evaluation()      'x is an array
    End Sub

    When math_evaluation is completed, RunWorkerCompleted should be triggered, but this does not happens.

    If I use in dowork not a function but a sub, it works:

    Public Sub BackgroundWorker1_DoWork(sender As Object, e As ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
             math_evaluation()      
    End Sub

    This is ok.

    What is wrong?



    Sunday, December 13, 2020 7:34 PM