This is a great example for a thread stop. Simple debugging trick for any looped process that needs the "e-brake" applied while making sure that the thread is working correctly. The idea is that you can manually stop a thread, to prevent that hanging sensation during any process. This works great with TCP and UDP protocol programs and ideal for all multi-threading programs.. feel free to implement as needed.
'Simulated loop that will continue for ever, 'Kinda like a persistant thread that will not stop Private Sub BackgroundProcess() Dim i As Integer = 1 Do While True ListBox1.Items.Add("Iterations: " + i) i += 1 Loop End Sub 'Thread created to handle the Background process Dim t As Thread t = New Thread(AddressOf Me.BackgroundProcess) t.Start() 'add a button to the form to handle the "e-Brake" to the thread Private Sub Button2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button2.Click t.Abort() End Sub
I am a network engineer that loves to code. I started on the Aquarius systems, and used just about every system until the home brew revolution started. Since then I have been an IT technician that loves to code and fix things that most people can't. This is my way of thanking those who have taught me well. I hope that I can help with any code that is puzzling to the masses.