C# check for a variable to equal?

C++, C#, Java, PHP, ect...
Post Reply
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

C# check for a variable to equal?

Post 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?
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: C# check for a variable to equal?

Post 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.
The indelible lord of tl;dr
kbrooker99206
Posts: 14
Joined: Thu Oct 08, 2015 2:34 am

Re: C# check for a variable to equal?

Post 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
Post Reply

Return to “Coding”