N
N
Nikolai Bogdanov2018-09-27 13:30:05
C++ / C#
Nikolai Bogdanov, 2018-09-27 13:30:05

How to make a progress bar for multiple tasks?

The layout is as follows: you need to compress the folder with audio files into another format (flac → mp3).
I would like to make a progress bar for this process, but there is a pitfall. Tasks are launched via Parallel.ForEach and report progress as follows: the Progress(object writer, long inputBytes, long outputBytes, bool finished) delegate is called at the specified frequency, which reports the number of bytes processed (inputBytes). In the case of one task, everything is simple, we divide the total file size by this inputBytes and multiply by 100. If several files are processed, it is easy to calculate their total size, but I don’t understand how to calculate the number of bytes processed. After all, inputBytes is always equal to the total number of bytes processed, not the number of bytes processed since the last occurrence of the event, and adding up results in wrong numbers. I hope I was able to explain clearly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Griboks, 2018-09-27
@Griboks

Report not the number of bytes, but the progress of the file. Display as the sum of the progress of all files divided by their number.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question