C# check for a variable to equal?

C++, C#, Java, PHP, ect...

C# check for a variable to equal?

Postby hallsofvallhalla » Tue Nov 04, 2014 12:12 pm

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
hallsofvallhalla
Site Admin
 
Posts: 11520
Images: 13
Joined: Wed Apr 22, 2009 6:29 pm
Location: mobile, al
Has thanked: 11 times
Been thanked: 115 times
Blog: View Blog (3)

Re: C# check for a variable to equal?

Postby Jackolantern » Tue Nov 04, 2014 3:25 pm

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
User avatar
Jackolantern
 
Posts: 10541
Joined: Wed Jul 01, 2009 6:00 pm
Location: Houston, TX
Has thanked: 20 times
Been thanked: 70 times
Blog: View Blog (1)

Re: C# check for a variable to equal?

Postby kbrooker99206 » Fri Jan 13, 2017 4:31 pm

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
kbrooker99206
 
Posts: 14
Joined: Wed Oct 07, 2015 9:34 pm
Has thanked: 0 time
Been thanked: 0 time


Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x