Friday, August 5, 2022

Pace

 Revisited nqdm this morning, to get a cleaner view of what precisely is being measured.

to recap, the range parameter is how many iterations one wants; sleep time is how long

the process stops between iterations. 


So the program goes fro reporting 1 second of elapsed time to two between 128 to 129

oterations, given a computer speed of ~64 iterations per second:


                                                                                  


Where does sleep time come into play. Below, the difference between a wait time

of one second and none at all:

                                                                                 

So sleep time sets the pace.      


                                                                       


                                                                  *     *     *

Found the solution to the rounding error. From Stackoverflow:

                                                                      


Using the +1in the code:




                                                  *     *     *

As for the fundamental issue of having a link between the progress bar and 

what is actually happening - somebody had to do it - went over to Microsoft to check

things out. They have example code for a file copy operation with a Boolean indicating

chunk 1 was successfully copied, before proceeding to chunk 2. Below(in C+):


[System.ComponentModel.DefaultBindingProperty("Value")]
public class ProgressBar : System.Windows.Forms.Control

private void CopyWithProgress(string[] filenames)
{
    // Display the ProgressBar control.
    pBar1.Visible = true;
    // Set Minimum to 1 to represent the first file being copied.
    pBar1.Minimum = 1;
    // Set Maximum to the total number of files to copy.
    pBar1.Maximum = filenames.Length;
    // Set the initial value of the ProgressBar.
    pBar1.Value = 1;
    // Set the Step property to a value of 1 to represent each file being copied.
    pBar1.Step = 1;
    
    // Loop through all files to copy.
    for (int x = 1; x <= filenames.Length; x++)
    {
        // Copy the file and increment the ProgressBar if successful.
        if(CopyFile(filenames[x-1]) == true)
        {
            // Perform the increment on the ProgressBar.
            pBar1.PerformStep();
        }
    }
}

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.progressbar?view=windowsdesktop-6.0

 Below, moving a large file from my desktop - and C: - to my other drive. All

the Microsoft features one would expect:



                                                               

No comments: