M
Mrs Nishad
Guest
Hello..
i have a windows application completed and now i want to add a windows service to the existing application. and i want to call a method of windows application from windows service. i use below code.. plz help
public partial class Service1 : ServiceBase
{
Timer time = new Timer();
string filename = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\BackupDetails.xml";
DBinfo1 dbinfo = new DBinfo1();
public Service1()
{
InitializeComponent();
}
Process p = new Process();
protected override void OnStart(string[] args)
{
time.Elapsed += new ElapsedEventHandler(OnElapsedTime);
time.Interval = 1000 * 60;
time.Start();
time.Enabled = true;
}
private void OnElapsedTime(object sender, ElapsedEventArgs e)
{
p.StartInfo.FileName = @"C:\Users\Mousmi Muthalib\Documents\Visual Studio 2015\Projects\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.Start();
}
protected override void OnStop()
{
p.Kill();
}
Mrs Nishad
Continue reading...
i have a windows application completed and now i want to add a windows service to the existing application. and i want to call a method of windows application from windows service. i use below code.. plz help
public partial class Service1 : ServiceBase
{
Timer time = new Timer();
string filename = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\BackupDetails.xml";
DBinfo1 dbinfo = new DBinfo1();
public Service1()
{
InitializeComponent();
}
Process p = new Process();
protected override void OnStart(string[] args)
{
time.Elapsed += new ElapsedEventHandler(OnElapsedTime);
time.Interval = 1000 * 60;
time.Start();
time.Enabled = true;
}
private void OnElapsedTime(object sender, ElapsedEventArgs e)
{
p.StartInfo.FileName = @"C:\Users\Mousmi Muthalib\Documents\Visual Studio 2015\Projects\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.Start();
}
protected override void OnStop()
{
p.Kill();
}
Mrs Nishad
Continue reading...