0

I am developing a exe for hard disk defragmentation. For this I am using StartDefragmentation(String DeviceName) method of IDefragmenter Interface for defragmentation of hard disk particular drive.

It works properly, but I have to also run progress bar to display the status of defragmentation, but I don't know how much time it takes to complete the defragmentation of a particular drive. If I know the actual time take by next thread than i will easily set progress bar Value and Maximum property.

My Code :

private void StartDefragmentation()
{           
    try {
        private IDefragmenter Defragmenter;
        Defragmenter.StartDefragmentation("D:\\");
        //please call Background Thread for setting progressbar Value Counter and  Maximum property which is time taken by StartDefragmentation method
    } catch {
    }
}

I already use this code, but it didn't help me:

Stopwatch sw = Stopwatch.StartNew();

Defragmenter.StartDefragmentation(f);
sw.Stop();
Double timeTaken = sw.Elapsed.TotalMilliseconds;
M4N
  • 94,805
  • 45
  • 217
  • 260
Khatri
  • 11
  • 4
  • Possible duplicate of [How do I display progress during a busy loop?](http://stackoverflow.com/questions/1194620/how-do-i-display-progress-during-a-busy-loop) – Tennyson H Feb 08 '16 at 19:38
  • can you give us some info about the library you are using, try not to use the time it won't help – Ahmad Alloush Feb 08 '16 at 19:57

0 Answers0