Waiting Screen Problem .net compact framework RRS feed

  • Question

  • How i can do it very very easy to display a form while a thread downloading data from the internet.... mean i know it
     the download thread is deep inside the project so i thinked i will display the form inside the downloader thread.... (that is the best method to display and when the thread exited the wait screen exited too) but the problem is the form appear but the animation dont work, i bet the cause of the thread is very occupied.... so how i can do it easily to display a form in another thread (the form will show the animation till the other thread working) and when the downloader thread finish his job (exit 0 ) the other thread  exit too (thread running the animation)
    Friday, July 31, 2009 9:41 AM


  • Hi sannyo,


    Based on my understanding, one way to achieve your goal is as follows:


    Downloading your file in blocks, in a while-loop, and invoke the method to update the processbar in each loop. When invoke, you pass the filesize(assuming you can get it), strLocal.Length which is length of bytes already downloaded.


    while ((bytesSize = strResponse.Read(downBuffer, 0, downBuffer.Length)) > 0)
                      // Write the data from the buffer to the local hard drive
                       strLocal.Write(downBuffer, 0, bytesSize);
                       // Invoke the method that updates the form's label and progress bar
                      this .Invoke(new UpdateProgessCallback (this .UpdateProgress), new object [] { strLocal.Length, fileSize });

    In the UpdateProgress function you update and draw the processbar.

    Refer to the following link for whole sample code



    Hope it helps.




    Monday, August 3, 2009 10:53 AM