Solved

VB.Net Threading

Posted on 2010-09-04
4
323 Views
Last Modified: 2012-05-10
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?
0
Comment
Question by:XGenwareS
  • 2
4 Comments
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 33606396
Can you post the filedelete class.
0
 
LVL 24

Expert Comment

by:alexey_gusev
ID: 33607285
"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.
0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 33609349
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

0
 
LVL 12

Accepted Solution

by:
Mohamed Abowarda earned 500 total points
ID: 33609362
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question