Solved

VB.Net Threading

Posted on 2010-09-04
4
336 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

733 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