Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I use VS2005 and I like to start with the basic template.</p> <p>Modify the Service class to this</p> <pre><code>using System; using System.ServiceProcess; using System.Timers; namespace WindowsService1 { public partial class Service1 : ServiceBase { //better is to read from settings or config file private readonly Double _interval = (new TimeSpan(1, 0, 0, 0)).TotalMilliseconds; private Timer m_Timer; public Service1() { InitializeComponent(); Init(); } private void Init() { m_Timer = new Timer(); m_Timer.BeginInit(); m_Timer.AutoReset = false; m_Timer.Enabled = true; m_Timer.Interval = 1000.0; m_Timer.Elapsed += m_Timer_Elapsed; m_Timer.EndInit(); } private void m_Timer_Elapsed(object sender, ElapsedEventArgs e) { //TODO WORK WORK WORK RestartTimer(); } private void RestartTimer() { m_Timer.Interval = _interval; m_Timer.Start(); } protected override void OnStart(string[] args) { base.OnStart(args); Start(); } protected override void OnStop() { Stop(); base.OnStop(); } public void Start() { m_Timer.Start(); } public new void Stop() { m_Timer.Stop(); } } } </code></pre> <p>Install using InstallUtil.exe, after you have added an installer : <a href="http://msdn.microsoft.com/en-us/library/ddhy0byf(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ddhy0byf(VS.80).aspx</a></p> <p>Keep the Init function small and fast, otherwise your service will not start with an error that the service did not respond in a timely fashion</p> <p>Hope this helps</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload