Reputation: 10164
how can i tell how long a:
objWebClient.DownloadData(strURL)
takes to complete?
i wish there was a property that contained this info but i couldn't find one...
Upvotes: 0
Views: 422
Reputation: 1503869
Just use a Stopwatch
:
Stopwatch sw = Stopwatch.StartNew();
webClient.DownloadData(...);
sw.Stop();
Console.WriteLine("Download took {0}ms", sw.ElapsedMilliseconds);
If you're using synchronous APIs, it's really easy. It's trickier with asynchronous APIs, but you'd just need to pass around the stopwatch in your state. Again, that's pretty easy if you use an anonymous method or lambda expression for your event handler, as it can capture the local variable.
Upvotes: 2