First of all this is your code:
Public Class myClass
Public Sub closeSomething()
End Sub
Public Sub doSomethingElse()
End Sub
Public Function doSomething() As String
Dim ret As String = "Blablabla"
Dim ThreadX As New System.Threading.Thread(AddressOf doSomethingElse)
ThreadX.IsBackground = True
ThreadX.Start()
While ThreadX.ThreadState <> System.Threading.ThreadState.Aborted AndAlso ThreadX.ThreadState <> System.Threading.ThreadState.Stopped
System.Threading.Thread.Sleep(1)
End While
Return ret
End Function
End Class
you'll have to specify more of what you want your program to do but the "<>" that your using is like a less than or greater than symbol added where its saying this is not this
so your code would say this
While ThreadX.ThreadState is not
System.Threading.ThreadState.Aborted AndAlso ThreadX.ThreadState is not
System.Threading.ThreadState.Stopped Then
System.Threading.Thread.Sleep(1)
End While
Return ret
for this code to even remotely work you would need "return ret" inside of the while
its just like an if statement
if this = this then
do this
else
do this
end if
your code should look like this:
Public Class myClass
Public Function doSomething() As String
Dim ret As String = "Blablabla"
Dim ThreadX As New System.Threading.Thread(AddressOf doSomethingElse)
ThreadX.IsBackground = True
ThreadX.Start()
While ThreadX.ThreadState <> System.Threading.ThreadState.Aborted AndAlso & _
ThreadX.ThreadState <> System.Threading.ThreadState.Stopped
System.Threading.Thread.Sleep(1)
Return ret
End While
End Function
Public Sub doSomethingElse()
msgbox("this is the doSomethingElse() sub")
End Sub
Public Sub closeSomething()
msgbox("this is the closeSomething() sub")
End Sub
End Class
you have to put somethin in the "doSomethingElse()" sub before you can call it from another sub, your basically saying
Dim ThreadX As New System.Threading.Thread(AddressOf NOTHING)
you cant dim something as nothing
also let me in on the reason you had the code:
ThreadX.IsBackground = True
ThreadX.Start()
i believe thats saying.. if doSomethingElse() is background then start thread doesnt make much sense
here is some example code for you to build from:
Private Sub Homescreen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim newthread As System.Threading.Thread
newthread = New Threading.Thread(AddressOf DanceLEDS)
newthread.Start()
Sub DanceLEDS()
Do process.start("notepad.exe")
Loop
End Sub