Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8376299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:23:53+00:00 2026-06-09T15:23:53+00:00

Public Sub downloadFile(ByVal url As String) LogFile.displayMessage(add url= & url) downloadURLs.Enqueue(url) If t Is

  • 0
Public Sub downloadFile(ByVal url As String)
        LogFile.displayMessage("add url=" & url)
        downloadURLs.Enqueue(url)

        If t Is Nothing Then
            LogFile.displayMessage("create new thread")
            t = New Thread(AddressOf ThreadedDownloadFile)
        End If

        If Not t.IsAlive Then
            LogFile.displayMessage("start thread")
            t.Start()
        End If

    End Sub


 Private Sub download()
        LogFile.displayMessage("thread running count=" & downloadURLs.Count)
        If downloadURLs.Count > 0 Then
            Dim client = New WebClient()
            AddHandler client.DownloadFileCompleted, AddressOf downloadFileCompleted
            AddHandler client.DownloadProgressChanged, AddressOf downloadProgressChanged

            Dim url = downloadURLs.Dequeue()
            LogFile.displayMessage("downloading url=" & url)
            url = WebRequest.Create(url).GetResponse.ResponseUri.AbsoluteUri
            Dim fileName = url.Substring(url.LastIndexOf("/") + 1)

            progress = 0
            LogFile.displayMessage("downloading NOW NOW NOW url=" & url)
            client.DownloadFile(New Uri(url), localAddress & fileName)
        End If
        LogFile.displayMessage("thread end")
    End Sub
    Private Sub downloadFileCompleted() 'ByVal sender As Object, ByVal e As DownloadStringCompletedEventArgs)
        LogFile.displayMessage("download complete ") ' & e.Result)

        LogFile.displayMessage("set next download going")
        download()
    End Sub

but on the second round it gets the url and then stops at the downloadfile.
it does this with downloadfileasync also.

i have seen many webpages discussing this, but none that fix it

does anyone know how this can be fixed?

ADDITIONAL details

i do start a new thread, but no matter how i do it, the webclient.downloadfile or downloadfileasync etc.
they all seem to work great the first time but then on second call, they do seem to download as a file appears, but the progress call is never made, and it never returns to complete.

I have tried dispose, then nothing it, then redeclare it, and even force garbage collect after dispose, nothing.

but it still does not want to work.

I am exploring doing the transfer myself, via streams

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:23:54+00:00Added an answer on June 9, 2026 at 3:23 pm

    The problem was nothing to do with the download, it was this code:-

    Dim wrequest = WebRequest.Create(url)
    Dim wresponce = wrequest.GetResponse()

        'save new url to be returned
        return wresponce.ResponseUri.AbsoluteUri
    

    I now call close and null the instances after there use.


    'making sure to close off unneeded resources after use
    wresponce.Close()
    wresponce = Nothing
    wrequest = Nothing

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

'Create field in table Public Sub createField(ByVal tableName As String, ByVal fieldName As String,
I have a VB method Public Sub append_text(ByVal s As String) f1.TextBox1.AppendText(s) End Sub
I've got the following code: Public Delegate Sub SetStatusBarTextDelegate(ByVal StatusText As String) Private Sub
Running the following code resulting in an HostException; Public Sub RunPowershellInConsole(ByVal scriptText As String)
Public Sub cleanTables(ByVal prOKDel As Short) Dim sqlParams(1) As SqlParameter Dim sqlProcName As String
Using the following function: Public Sub SendMail(ByVal SendFrom As String, ByVal SendTo As String,
Public Sub WriteTextFile(ByVal SourceToWrite As String, ByVal LocationToWrite As String) Dim file As System.IO.StreamWriter
Is this possible? Public Class Foo public var as string public sub Load(byval filename
<Extension()> _ Public Sub Save(ByVal b As Bitmap, ByVal FileName As String, ByVal Compression
Public Sub New() If GridElement.typeList(getId(), getLayer()) Is Nothing Then GridElement.typeList(getid(),getlayer()) = GetType(me) End If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.