Windows Application in Windows Service

  • Thread starter Thread starter Mrs Nishad
  • Start date Start date
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...
 

Similar threads

T
Replies
0
Views
115
thereisnopatchforhumancruelty
T
V
Replies
0
Views
127
Vamshi K J
V
D
Replies
0
Views
57
Domleg
D
N
Replies
0
Views
140
nopatch4humancruelty
N
Back
Top