hi experts,
I see quite a lot of questions on this error but haven't figured it out.
Here's the situation
MAIN FORM-->User clicks on menu and is presented with new form "CalculationsForm"
Dim f As New CalculationsForm()
f.ShowDialog()
User picks some stuff and clicks "OK" on "CalculationsForm. "OK" starts the calculations
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Try
Me.OK_Button.Enabled = False
ProgressLabel.Show()
ProgressBar1.Show()
ProgressStatus = 0
'start calculations here
BackgroundWorker1.RunWorke
rAsync()
Catch ex As Exception
Utils.LogException(ex)
End Try
End Sub
Private Sub BackgroundWorker1_DoWork(B
yVal sender As System.Object, ByVal e As System.ComponentModel.DoWo
rkEventArg
s) Handles BackgroundWorker1.DoWork
do lots of stuff here.....
'finished doing stuff
BackgroundWorker1.ReportPr
ogress(100
)
'Now close the form: ERROR HERE!
Me.close
end sub
The line "Me.close" gives error. I have tried putting it in the Backgroundworker completed too but no joy.
I just want to close the form on completion of calcs without this cross-thread error.
Help please thank-you
Start Free Trial