Click here to Skip to main content
15,920,217 members
Home / Discussions / C#
   

C#

 
AnswerRe: Need help with error checking for Dns.GetHostEntry [modified] Pin
Shameel11-Aug-11 0:49
professionalShameel11-Aug-11 0:49 
GeneralRe: Need help with error checking for Dns.GetHostEntry Pin
turbosupramk311-Aug-11 3:27
turbosupramk311-Aug-11 3:27 
GeneralRe: Need help with error checking for Dns.GetHostEntry Pin
Shameel11-Aug-11 4:05
professionalShameel11-Aug-11 4:05 
GeneralRe: Need help with error checking for Dns.GetHostEntry Pin
turbosupramk311-Aug-11 4:52
turbosupramk311-Aug-11 4:52 
GeneralRe: Need help with error checking for Dns.GetHostEntry Pin
BobJanova11-Aug-11 5:39
BobJanova11-Aug-11 5:39 
GeneralRe: Need help with error checking for Dns.GetHostEntry Pin
Shameel11-Aug-11 5:48
professionalShameel11-Aug-11 5:48 
QuestionWhat is the best method to figure out elapsed time in a BackgroundWorker thread? Pin
bbranded10-Aug-11 5:05
bbranded10-Aug-11 5:05 
AnswerRe: What is the best method to figure out elapsed time in a BackgroundWorker thread? Pin
Ian Shlasko10-Aug-11 5:15
Ian Shlasko10-Aug-11 5:15 
A BackgroundWorker can report progress... Turn on the WorkerSupportsProgress flag, cast the "sender" to a BackgroundWorker and use that to send a progress report. You're supposed to send the completion percentage as an integer, but you can also supply a "state" object along with that, which could contain the bytes read.

Now, if you want to get the amount of data read in the past X seconds, you need a rolling buffer... Maybe it could go something like this:

1) Every N bytes (Maybe every 500KB or so), the worker reports the bytes read as a progress event
2) The handler dumps that into a rolling buffer with a time stamp (DateTime), and maintains a pointer to the oldest record within the desired time span.
3) The speed is calculated as (BytesRead[current] - BytesRead[oldest]) / (TimeStamp[current] - TimeStamp[oldest]) and put into a class-level variable.
4) Every so often, your timer can just read that variable to report the speed (Or whatever you want to do with it)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)

GeneralRe: What is the best method to figure out elapsed time in a BackgroundWorker thread? [modified] Pin
bbranded10-Aug-11 5:27
bbranded10-Aug-11 5:27 
GeneralRe: What is the best method to figure out elapsed time in a BackgroundWorker thread? Pin
Ian Shlasko10-Aug-11 5:43
Ian Shlasko10-Aug-11 5:43 
GeneralRe: What is the best method to figure out elapsed time in a BackgroundWorker thread? [modified] Pin
bbranded11-Aug-11 7:17
bbranded11-Aug-11 7:17 
GeneralRe: What is the best method to figure out elapsed time in a BackgroundWorker thread? Pin
Shameel10-Aug-11 9:32
professionalShameel10-Aug-11 9:32 
AnswerRe: What is the best method to figure out elapsed time in a BackgroundWorker thread? Pin
PIEBALDconsult10-Aug-11 15:34
mvePIEBALDconsult10-Aug-11 15:34 
GeneralRe: What is the best method to figure out elapsed time in a BackgroundWorker thread? Pin
bbranded10-Aug-11 15:36
bbranded10-Aug-11 15:36 
GeneralRe: What is the best method to figure out elapsed time in a BackgroundWorker thread? Pin
PIEBALDconsult10-Aug-11 17:19
mvePIEBALDconsult10-Aug-11 17:19 
GeneralRe: What is the best method to figure out elapsed time in a BackgroundWorker thread? Pin
bbranded11-Aug-11 1:27
bbranded11-Aug-11 1:27 
QuestionFiltering Problem in Sql Syntax using C#.net Pin
nassimnastaran10-Aug-11 0:17
nassimnastaran10-Aug-11 0:17 
AnswerRe: Filtering Problem in Sql Syntax using C#.net Pin
Shameel10-Aug-11 0:38
professionalShameel10-Aug-11 0:38 
AnswerRe: Filtering Problem in Sql Syntax using C#.net Pin
MicroVirus10-Aug-11 3:30
MicroVirus10-Aug-11 3:30 
GeneralRe: Filtering Problem in Sql Syntax using C#.net Pin
GenJerDan10-Aug-11 3:54
GenJerDan10-Aug-11 3:54 
GeneralRe: Filtering Problem in Sql Syntax using C#.net Pin
BobJanova10-Aug-11 3:58
BobJanova10-Aug-11 3:58 
GeneralRe: Filtering Problem in Sql Syntax using C#.net Pin
GenJerDan10-Aug-11 4:01
GenJerDan10-Aug-11 4:01 
GeneralRe: Filtering Problem in Sql Syntax using C#.net Pin
MicroVirus10-Aug-11 4:05
MicroVirus10-Aug-11 4:05 
AnswerRe: Filtering Problem in Sql Syntax using C#.net Pin
BobJanova10-Aug-11 3:57
BobJanova10-Aug-11 3:57 
GeneralRe: Filtering Problem in Sql Syntax using C#.net Pin
nassimnastaran10-Aug-11 4:23
nassimnastaran10-Aug-11 4:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.