Jul 25, 2014 04:36 PM
(This post was last modified: Jul 25, 2014 05:04 PM by SIM-1456245.)
Hey people. I was bored and decided to (as always) over code a class for measuring download speeds. It will basically download a file and calculate the size of it the time it took to download and calculate the speed in a nice structure(bps, Kbps, Mbps, Gbps). In the example there is a link given to a file that is exactly 1.000.000 bytes big. I will have to note that this will give you BITS PER SECOND not BYTES PER SECONDS. And also it takes in measurement 1 Mb = 1000 Kb. You need to specify the URL in the New method as a argument. And when you want to measure, you need to call the Measure() method. When it finishes, the Complete() event will be risen. It has event arguments. It will give you the file size, time needed to download and a structure with the speed in 4 different measurements(bps, Kbps, Mbps, Gbps). The Error event is risen whenever there is a error, don't bitch about this, because I like to handle errors like that, and that's how I do it. There is also if you notice another method called SimpleMeasure(), that is basically the whole class in one very tiny method. It is not async, but for anyone that will say that it can be done shorter, I proved him right. Enough talking here is the code(example included): http://pastebin.com/Tj9m4ZzH
UPDATE: There is not a string representation with the appropriate measurement represented as string in the event args as a text string variable.
UPDATE: There is not a string representation with the appropriate measurement represented as string in the event args as a text string variable.


