Question

I am creating a Windows Application which will run in the background and run a query every 5 mins. If it finds a record based on the criteria the application will make a sound to notify me. How can run a query inside a Windows Application every 5 mins? and how can i specify the connection string from within a memo box in my form?

I have created the application, added the button to start the app and added the textbox for the connection string.

Was it helpful?

Solution

create your timer

Timer timer = new Timer();

set it up

timer.Tick += new EventHandler(timer_Tick); 
timer.Interval = (1000 * 60 * 5);           
timer.Enabled = true;       
timer.Start();           

do stuff when it ticks

void timer_Tick(object sender, EventArgs e)
{
    //run query, play noise
}

OTHER TIPS

There are many different ways. I've worked on projects that use schedulers that are configured in the web.config. There are other projects that use the Windows Scheduler on the server to run something every so often.

This question--How to write C# Scheduler has a way to do it within the C# code itself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top