Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. DownloadfileCompleted event

DownloadfileCompleted event

Scheduled Pinned Locked Moved Windows Forms
helpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ashok_rgm
    wrote on last edited by
    #1

    Hello All, I have a problem with event that I am generating after file download. The flow is like this 1.initialize the DownloadfileCompleted event handler. 2.DownloadFileAsync(URI,str2) 3.After download completed it should display "download complete" 4.return "downloaded successfully" but the problem is if the downloading takes more time it is directly coming to step 4. without waiting for completeion of step 3. how can i make step 4 to wait until completeion of step3.. Thanks in Advance, Ashok

    ashok

    L 1 Reply Last reply
    0
    • A ashok_rgm

      Hello All, I have a problem with event that I am generating after file download. The flow is like this 1.initialize the DownloadfileCompleted event handler. 2.DownloadFileAsync(URI,str2) 3.After download completed it should display "download complete" 4.return "downloaded successfully" but the problem is if the downloading takes more time it is directly coming to step 4. without waiting for completeion of step 3. how can i make step 4 to wait until completeion of step3.. Thanks in Advance, Ashok

      ashok

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      How does step 1 look like in code?

      I are troll :)

      A 1 Reply Last reply
      0
      • L Lost User

        How does step 1 look like in code?

        I are troll :)

        A Offline
        A Offline
        ashok_rgm
        wrote on last edited by
        #3

        1. objWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(Event_DownloadFileCompleted); 2.objWebClient.DownloadFileAsync(new Uri(p_strSourcePath), l_strDestinationPath); 3.MessageBox.Show("Updated Successfully"); 4.public void Event_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { MessageBox.Show("Download Completed"); }

        ashok

        C L 2 Replies Last reply
        0
        • A ashok_rgm

          1. objWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(Event_DownloadFileCompleted); 2.objWebClient.DownloadFileAsync(new Uri(p_strSourcePath), l_strDestinationPath); 3.MessageBox.Show("Updated Successfully"); 4.public void Event_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { MessageBox.Show("Download Completed"); }

          ashok

          C Offline
          C Offline
          CooperWu
          wrote on last edited by
          #4

          I wrote same code before, it works well. please check source file before download, and you add try catch block to get whether exception.

          Glad to discuss with you and best wishes.

          1 Reply Last reply
          0
          • A ashok_rgm

            1. objWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(Event_DownloadFileCompleted); 2.objWebClient.DownloadFileAsync(new Uri(p_strSourcePath), l_strDestinationPath); 3.MessageBox.Show("Updated Successfully"); 4.public void Event_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { MessageBox.Show("Download Completed"); }

            ashok

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            To make it block the execution;

            public bool downloadIsDone = false;

            public void ZeDownloadMechanism()
            {
            objWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(
            Event_DownloadFileCompleted);

            objWebClient.DownloadFileAsync(new Uri(p_strSourcePath), l_strDestinationPath);

            while (!downloadIsDone)
            Application.DoEvents();

            MessageBox.Show("Updated Successfully");
            }

            public void Event_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
            {
            downloadIsDone = true;
            MessageBox.Show("Download Completed");
            }

            Why would you want to block execution on a Async-download?

            I are troll :)

            A 1 Reply Last reply
            0
            • L Lost User

              To make it block the execution;

              public bool downloadIsDone = false;

              public void ZeDownloadMechanism()
              {
              objWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(
              Event_DownloadFileCompleted);

              objWebClient.DownloadFileAsync(new Uri(p_strSourcePath), l_strDestinationPath);

              while (!downloadIsDone)
              Application.DoEvents();

              MessageBox.Show("Updated Successfully");
              }

              public void Event_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
              {
              downloadIsDone = true;
              MessageBox.Show("Download Completed");
              }

              Why would you want to block execution on a Async-download?

              I are troll :)

              A Offline
              A Offline
              ashok_rgm
              wrote on last edited by
              #6

              ThanQ for your help, can u brief the differences between normal download and async-download?

              ashok

              L 1 Reply Last reply
              0
              • A ashok_rgm

                ThanQ for your help, can u brief the differences between normal download and async-download?

                ashok

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                Sync (normal) blocks execution, Async doesn't. Simple example, if you normally play a soundfile in VB6, then the computer will not execute anything until the sound is finished playing. If you play it async, the computer will "move on", and execute your next instruction. Hope this helps :)

                I are troll :)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups