cross Thread not valid

  • Thread starter Thread starter elun219
  • Start date Start date
E

elun219

Hi Guys,

I have a question on the Vb.net code I am working on. I have a winform
that has a button that starts a thread, I would like to close the
winform when thread finishes or crashes. Is there a way to call
winform.close from the thread?

Thank you

Alan
 
I have a question on the Vb.net code I am working on. I have a winform
that has a button that starts a thread, I would like to close the
winform when thread finishes or crashes. Is there a way to call
winform.close from the thread?

Yes, you can call it by calling the form's 'Invoke' or 'BeginInvoke' method.
 
Thanks a lot for helping. My code looks like the following:
private sub run()
try
calculate()
winform.close
catch ex
winform.close
end try
end function

public sub button1_onclick()
dim a as thread (addressof run)
a.start
end sub

Can you help point out where I should use invoke and beginInvoke?

Thank you!
 
Back
Top