Hello. I am unsure how to proceed about printing progress in my program.

Suppose the program is processing a very big file and is iterating the file's bytes using a for loop. The processing takes several minutes and I want a progress percentage be printed every 2 seconds in this manner:

Progress: 0.40%
Progress: 3.20%
Progress: 5.73%

Is it a good idea to std.concurrency.spawn a new thread and pass to it
    cast(float)i * 100 / fileSize
somehow? If not, what's a better way to do this?

This example code shows my situation:

    MmFile  input       = new MmFile(/* ... */);
    ulong   fileSize    = input.length;

    for (ulong i = 0; i < fileSize; ++i)
    {
        // ...
    }

Thanks in advance.

Reply via email to