To start a new thread the method can't take arguments. THere are ways around this though.
Here is an example of threading:
VB Code:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim t As New Threading.Thread(AddressOf DoLongSomething) t.Start() End Sub Private Sub DoLongSomething() Dim cnt As Integer = 0 Do Until cnt = cnt.MaxValue cnt += 1 Loop MsgBox("Done") End Sub
If you put a textbox and a button (the button links to the one in code) then press the button to start the looping code and notice you can still interact with the textbox and rest of the program no problem. You could even put something in the closing event to warn the user that a thread is still running before they shut down (if they shut down with one running that is).




Reply With Quote