Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How can we keep calling OnStart() in Started condition of Windows Service in C#

How can we keep calling OnStart() in Started condition of Windows Service in C#

Scheduled Pinned Locked Moved C#
csharphelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Piyush Vaishnav
    wrote on last edited by
    #1

    Hi all, I have created one windows services in C#. In OnStart method i want to start external exe at particular given time by user. For that i need to keep comparing time of system and user given time. But OnStart method calls only one time when starting that service. Is there any other event or methods which will call continuosly when service in Started condition. I feel happy when will get alternative solution for the problem. Thanks guys......

    B J realJSOPR 3 Replies Last reply
    0
    • P Piyush Vaishnav

      Hi all, I have created one windows services in C#. In OnStart method i want to start external exe at particular given time by user. For that i need to keep comparing time of system and user given time. But OnStart method calls only one time when starting that service. Is there any other event or methods which will call continuosly when service in Started condition. I feel happy when will get alternative solution for the problem. Thanks guys......

      B Offline
      B Offline
      bcozican
      wrote on last edited by
      #2

      Create a global Timer instance like System.Timers.Timer or System.Threading.Timer in your service class that you enable and start in your OnStart() event. Then every time the timer event fires you can perform your logic you need to. And you can set it to fire as often as you like. Hope this helps.

      1 Reply Last reply
      0
      • P Piyush Vaishnav

        Hi all, I have created one windows services in C#. In OnStart method i want to start external exe at particular given time by user. For that i need to keep comparing time of system and user given time. But OnStart method calls only one time when starting that service. Is there any other event or methods which will call continuosly when service in Started condition. I feel happy when will get alternative solution for the problem. Thanks guys......

        J Offline
        J Offline
        Jaffer Mumtaz
        wrote on last edited by
        #3

        Hi, You could place a timer control on your service and do your programming logic in timer elapse event. Set the timer elapse time say 10 seconds or what ever you want and launch your exe. cheers

        1 Reply Last reply
        0
        • P Piyush Vaishnav

          Hi all, I have created one windows services in C#. In OnStart method i want to start external exe at particular given time by user. For that i need to keep comparing time of system and user given time. But OnStart method calls only one time when starting that service. Is there any other event or methods which will call continuosly when service in Started condition. I feel happy when will get alternative solution for the problem. Thanks guys......

          realJSOPR Offline
          realJSOPR Offline
          realJSOP
          wrote on last edited by
          #4

          Use a BackgroundWorker object. Timers are okay, but they send the lowest priority message Windows has, and it's not guaranteed to be handled in a busy system. So, to avoid the issue, use a BackgroundWorker.

          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
          -----
          "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups