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?
C# check for a variable to equal?
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: C# check for a variable to equal?
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.
The indelible lord of tl;dr
-
- Posts: 14
- Joined: Thu Oct 08, 2015 2:34 am
Re: C# check for a variable to equal?
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
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
you get the idea... Stackoverflow usually has good c# info btw
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
}
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
}