Link to home
Start Free TrialLog in
Avatar of XGenwareS
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?
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

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.
Private thread As New Threading.Thread(AddressOf functionName)

Private Sub functionName()
' TODO: Add your code here...
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Brad Brett
Brad Brett
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial