Hello again. I'm having a hard time stopping a thread. Whenever i close my main form the application doesn't stop because there is a thread still running. I tried every solution I can find in the web but i can't make it work. Can someone help me with this?
Public Class Main
Dim ServerThread As New System.Threading.Thread(AddressOf netLink.Main)
Private Sub Main_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
SyncLock ServerThread
ServerThread.Abort()
End SyncLock
Call netLink.stopThread() 'I called a public sub in my module to change the value of a Boolean variable to false so that all "While loops" can stop
End Sub
Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ServerThread.Start()
End Sub
End Class