Progress printing with threads?
ab396356 at users.sourceforge.net
Wed Jul 1 07:52:28 UTC 2020
Hello. I am unsure how to proceed about printing progress in my
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:
Is it a good idea to std.concurrency.spawn a new thread and pass
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.
More information about the Digitalmars-d-learn