CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Deploying Windows Server 2008 with System Center
  • Remote Desktop Protocol Performance Improvements in Windows Server 2008 R2 and Windows 7
  • The Microsoft Dynamics CRM Security Model
  • SQL Server Modeling Services with Microsoft Visual Studio 2010 Beta 2

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > .NET Programming > C-Sharp Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    C-Sharp Programming Post questions, answers, and comments about C#.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old August 19th, 2009, 04:38 AM
    meenus meenus is offline
    Member
     
    Join Date: Jul 2008
    Posts: 27
    meenus is an unknown quantity at this point (<10)
    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.
    Reply With Quote
      #2    
    Old August 19th, 2009, 05:30 AM
    dannystommen dannystommen is offline
    Member +
     
    Join Date: Sep 2008
    Location: Netherlands
    Posts: 651
    dannystommen is a jewel in the rough (200+) dannystommen is a jewel in the rough (200+) dannystommen is a jewel in the rough (200+)
    Re: How to create schedule program in c#

    You could create a Windows Service that has a timer running.

    Take a look here to create a Windows Service
    Reply With Quote
      #3    
    Old August 19th, 2009, 02:57 PM
    Shuja Ali's Avatar
    Shuja Ali Shuja Ali is offline
    Super Mod
    Power Poster
     
    Join Date: Jun 2004
    Location: Kashmir, India
    Posts: 6,803
    Shuja Ali has a reputation beyond repute (3000+) Shuja Ali has a reputation beyond repute (3000+) Shuja Ali has a reputation beyond repute (3000+) Shuja Ali has a reputation beyond repute (3000+) Shuja Ali has a reputation beyond repute (3000+) Shuja Ali has a reputation beyond repute (3000+) Shuja Ali has a reputation beyond repute (3000+) Shuja Ali has a reputation beyond repute (3000+) Shuja Ali has a reputation beyond repute (3000+) Shuja Ali has a reputation beyond repute (3000+) Shuja Ali has a reputation beyond repute (3000+)
    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
    Reply With Quote
      #4    
    Old August 20th, 2009, 01:54 AM
    meenus meenus is offline
    Member
     
    Join Date: Jul 2008
    Posts: 27
    meenus is an unknown quantity at this point (<10)
    Re: How to create schedule program in c#

    thank you
    Reply With Quote
      #5    
    Old August 20th, 2009, 02:33 AM
    rliq's Avatar
    rliq rliq is offline
    Member
     
    Join Date: Jun 2001
    Location: Melbourne/Aus
    Posts: 334
    rliq has a spectacular aura about (100+) rliq has a spectacular aura about (100+)
    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.
    ---
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > .NET Programming > C-Sharp Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 01:41 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.