XGenwareS
asked on
VB.Net Threading
I have a threaded function like this:
Private Function Phone() As String
Dim req As HttpWebRequest = WebRequest.Create("www.webserver.com/command.txt)
Dim res As HttpWebResponse = req.GetResponse()
Dim Stream As Stream = res.GetResponseStream()
Dim sr As StreamReader = New StreamReader(Stream)
Dim cmd As String = sr.ReadToEnd
Select Case Command()
Case Command.StartsWith(delete" )
dim a as new filedelete class
a.delete
End Select
Return 0
End Function
FileDelete is a class I made to delete a file. But when I call it from another thread, it doesn't work. Any help?
Private Function Phone() As String
Dim req As HttpWebRequest = WebRequest.Create("www.webserver.com/command.txt)
Dim res As HttpWebResponse = req.GetResponse()
Dim Stream As Stream = res.GetResponseStream()
Dim sr As StreamReader = New StreamReader(Stream)
Dim cmd As String = sr.ReadToEnd
Select Case Command()
Case Command.StartsWith(delete"
dim a as new filedelete class
a.delete
End Select
Return 0
End Function
FileDelete is a class I made to delete a file. But when I call it from another thread, it doesn't work. Any help?
Can you post the filedelete class.
"doesn't work" as in what meaning? samples for success and failure would be very helpful along with the FileDelete class code - even if it's not complete but enough to sketch its main features, so we can suggest what's wrong with it.
It seems you are doing something wrong, try the following code to call the function from another thread:
Call thread.Start() to start the thread.
Change 'functionName' with the function you want to use.
Call thread.Start() to start the thread.
Change 'functionName' with the function you want to use.
Private thread As New Threading.Thread(AddressOf functionName)
Private Sub functionName()
' TODO: Add your code here...
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.