Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.
progMain.Value = e.ProgressPercentage;
if ((DateTime.Now - _startDate).Seconds > 0)
{
double kbPerSecond = (e.BytesReceived / 1000) (DateTime.Now - _startDate).Seconds;
double remainingTimeSeconds
= (((e.TotalBytesToReceive - e.BytesReceived) / 1000) / kbPerSecond);
string remainingTimeDisplay
= string.Empty;
if (remainingTimeSeconds
> 3600)
{
remainingTimeDisplay
+= ((int)(remainingTimeSeconds) /
3600).ToString("n0") + " hours, ";
remainingTimeSeconds %= 3600;
}
if (remainingTimeSeconds
> 60)
{
remainingTimeDisplay += ((int)(remainingTimeSeconds)
/ 60).ToString("n0") + " minutes, ";
remainingTimeSeconds %= 60;
}
remainingTimeDisplay += ((int)remainingTimeSeconds).ToString("n0") + "
seconds remaining";
this.Text =
(e.BytesReceived / 1000).ToString("n0")
+ " bytes received of " +
(e.TotalBytesToReceive / 1000).ToString("n0") + ":
" + e.ProgressPercentage.ToString() + "%
at " +
kbPerSecond.ToString("n0")
+ "kb/s - " +
remainingTimeDisplay;
}
4. Finally we'll do some display clean up.
progMain.Value = 0;
There you have it, your very own download dialog. The same concept can easily be extended to work with the BackgroundWorker as well for any process running in its own thread.
claudio centenoPosted Aug 5, 2012, 5:12 AM
Muy buen articulo xD