[Solved] how to use windows service in windows form application [closed]


You can use Timer to periodically update the database

Timer timer = new Timer();
timer.Tick += new EventHandler(timer_Tick); // Everytime timer ticks, timer_Tick will be called
    timer.Interval = (10) * (1);             // Timer will tick evert 10 seconds
    timer.Enabled = true;                       // Enable the timer
    timer.Start();

void timer_Tick(object sender, EventArgs e)
{
    //Put your technique for updating database here
}

You can invoke service like this

using System.ServiceProcess;
ServiceController sc = new ServiceController("My service name");
if (sc.Status == ServiceControllerStatus.Stopped)
{
   sc.Start();
}

2

solved how to use windows service in windows form application [closed]