What do you use to realize each point? Which libraries?
If you use some external, compiled libraries, you can catch the output and parse it:
var proc = new Process {
StartInfo = new ProcessStartInfo {
FileName = "program.exe",
Arguments = "command line arguments to your executable",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
And start the process:
proc.Start();
while (!proc.StandardOutput.EndOfStream) {
string line = proc.StandardOutput.ReadLine();
// parse your output
}
- When you download a file, you can use just a simple pattern:
bytes_already_downloaded/bytes_total * 100 = download_progress_in_%
If you use some classes (you have source code), you can create a callback action:
public void DoSomethingMethod(Action<int> progressCallback)
{
while(true)
{
// do something here
// return the progress
int progress = stuff_done / stuff_total * 100;
progressCallback(progress);
}
}
And how to use it?
MyClass.DoSomethingMethod(delegate(int i) { progressBar.Progress = i; });
Or just:
MyClass.DoSomethingMethod(i => progressBar.Progress = i);
If you mean something else, you can specify it in the comment. I will try to answer:)