System.Threading.Thread error.

  • Thread starter Thread starter Vjay77
  • Start date Start date
V

Vjay77

In this code:


Private Sub downloadBtn_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not (Me.downloadUrlTextBox.Text = "")
Then
Me.outputGroupBox.Enabled = True
Me.bytesDownloadedTextBox.Text = ""
Me.totalBytesTextBox.Text = ""
Me.progressBar.Minimum = 0
Me.progressBar.Maximum = 0
Me.progressBar.Value = 0
Dim dl As DownloadThread = New DownloadThread
dl.DownloadUrl = Me.downloadUrlTextBox.Text
AddHandler dl.CompleteCallback, AddressOf
DownloadCompleteCallback
AddHandler dl.ProgressCallback, AddressOf
DownloadProgressCallback
Dim t As System.Threading.Thread = New
System.Threading.Thread(New
System.Threading.ThreadStart(dl.Download))
t.Start()
End If



This line:

[code:1:58b099c7e5]
Dim t As System.Threading.Thread = New System.Threading.Thread(New
System.Threading.ThreadStart(dl.Download))
[/code:1:58b099c7e5]

shows underlined as being in error... and I can't figure out what is
wrong with my syntax...

please help

vjay




http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
 
What is the error message?

Just a guess, but "dl.download" should take no parameters. Also you need to
use the "addressof" operator in the constructor of the threadstart like this
(watch out for line breaks):

------------------------
Dim t As System.Threading.Thread = New System.Threading.Thread(New
System.Threading.ThreadStart(addressof dl.Download))
-------------------------------

A shorthand version would be:

------------------------
Dim t As new System.Threading.Thread(addressof dl.Download)
-------------------------------

Hope this helps,

Trev.

Vjay77 said:
In this code:


Private Sub downloadBtn_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
If Not (Me.downloadUrlTextBox.Text = "")
Then
Me.outputGroupBox.Enabled = True
Me.bytesDownloadedTextBox.Text = ""
Me.totalBytesTextBox.Text = ""
Me.progressBar.Minimum = 0
Me.progressBar.Maximum = 0
Me.progressBar.Value = 0
Dim dl As DownloadThread = New DownloadThread
dl.DownloadUrl = Me.downloadUrlTextBox.Text
AddHandler dl.CompleteCallback, AddressOf
DownloadCompleteCallback
AddHandler dl.ProgressCallback, AddressOf
DownloadProgressCallback
Dim t As System.Threading.Thread = New
System.Threading.Thread(New
System.Threading.ThreadStart(dl.Download))
t.Start()
End If



This line:

[code:1:58b099c7e5]
Dim t As System.Threading.Thread = New System.Threading.Thread(New
System.Threading.ThreadStart(dl.Download))
[/code:1:58b099c7e5]

shows underlined as being in error... and I can't figure out what is
wrong with my syntax...

please help

vjay



----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Back
Top