Page 1 of 1

C# check for a variable to equal?

Posted: Tue Nov 04, 2014 5:12 pm
by hallsofvallhalla
So I am using an API from another company and it allows me to run reports via this API. It has a method that runs it, a method to check if it is finished running, then a method to get the results.

What is the best way in C# to check to see if report is finished say every 5 seconds?

Re: C# check for a variable to equal?

Posted: Tue Nov 04, 2014 8:25 pm
by Jackolantern
I have never used it before, but I believe the Timer class would be best for this. It raises an event based on time, so you could use it to continuously check if the operation is done. About the only tutorial I could find is here.

Re: C# check for a variable to equal?

Posted: Fri Jan 13, 2017 9:31 pm
by kbrooker99206
well there is a few ways to do it...
Firs you can use the timer control and just put in the event handler like so

Code: Select all

private void timer1_Tick(object sender, EventArgs e)
        {
//Do your stuff here set the timer tick property to 5000 and bamn
        }
or you can have it check the time and set a time to check in a loop or the main loop of the program.cs file

Code: Select all

DateTime lastcheck = DateTime.Now;

if(DateTime.now >= lastcheck.AddSeconds(5)){
//Do your stuff here

//at end of your stuff
lastCheck=DateTime.Now
}
you get the idea... Stackoverflow usually has good c# info btw