Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show a form in windows service.

I want to load a form in OnStart() method in my windows service; here is my code. It is not working. Can you please provide any help ?

protected override void OnStart(string[] args)
{
    Form1 fr = new Form1();
    fr.Show();
}
like image 648
Farna Avatar asked Mar 06 '11 15:03

Farna


1 Answers

You can't use services that way. Services can't interact with desktop directly, because they run in another WindowsStation from the logged in users session. You need to create another application that will communicate with your service.

How to make communication you can read on MSDN and in this example. Some ideas also described already on StackOverflow.

like image 138
kyrylomyr Avatar answered Oct 04 '22 15:10

kyrylomyr