Click here to Skip to main content
15,917,968 members
Home / Discussions / C#
   

C#

 
QuestionNeed help with error checking for Dns.GetHostEntry Pin
turbosupramk310-Aug-11 8:59
turbosupramk310-Aug-11 8:59 
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 
Hello,

I am attempting to create a benchmarking software that reads the contents of files.

I would like to report, every five seconds, the average speed per MB read, the speed in MB/sec.

I don't think that calculating a TimeSpan will be the best method, as it will definitely be inaccurate overtime (increasing in inaccuracy).


If I use a timer in the BackgroundWorker thread, how do I pass a variable to the ElapsedEventHandler that contains the amount of data read?

C#
        private void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            MessageBox.Show(AmountOfBytesRead);
        }

        public void ReadFiles(string TargetDirectory, bool RecursivePlz, string LogFilename)
        {

            DateTime StartOfReading = DateTime.Now;

            System.Timers.Timer timer = new System.Timers.Timer();
            timer = new System.Timers.Timer();
            timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            timer.Interval = 5000;
            timer.Start();

            ...
            //read some file(s) and record the amount of bytes read to a variable AmountOfBytesRead
}




Thanks,

Matt
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 
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 

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.