| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| C-Sharp Programming Post questions, answers, and comments about C#. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to create schedule program in c#
Hi
I want to execute some collection of SQL statements in SQL Server 2005DataBase with time condition based ,So i need to create the Schedule Program in c# ,could you explain the Schedule concepts or send example programs. |
|
#3
|
||||
|
||||
|
Re: How to create schedule program in c#
Or maybe you could write a simple Console Application and schedule it using the Task Scheduler.
__________________
Use [code]your code here[/code] tags when you post source code Search here before you post your question, someone might have already asked it before. My Articles |
|
#4
|
|||
|
|||
|
Re: How to create schedule program in c#
thank you
|
|
#5
|
||||
|
||||
|
Re: How to create schedule program in c#
if you use a Windows Service with a Timer, do not drag a Timer control onto the design service, but rather use the System.Threading.Timer class... eg to help get you started....
Code:
using System;
using System.ServiceProcess;
using System.Threading;
namespace MyProject
{
public partial class TestService : ServiceBase
{
private Timer _timer; // System.Threading.Timer
public TestService()
{
InitializeComponent();
}
protected override void OnStart(String[] args)
{
Int32 interval = 20000;
object state = null; // put something in here if your Tick callback needs it
try
{
// third parameter of 0 means start immediately
_timer = new Timer(new TimerCallback(OnTick), state, 0, interval);
}
catch (Exception ex)
{
// uh oh
}
}
protected override void OnStop()
{
_timer.Change(Timeout.Infinite, Timeout.Infinite);
}
private void OnTick(object state)
{
// react to the Tick
}
}
}
__________________
--- Rob I'm based on a true story, set sometime in the near future. A "Dumb" question, is one that you wished you had asked when you had the chance. --- |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|