Kyah

I'd like to have your help for showing me how to display a form from a windows services application.

I tried the following way, but I can't see my form

protected override void OnStart(string[] args)

{

System.Threading.ThreadStart winstart = new ThreadStart(DisplayIt);

StartWin = new Thread(winstart);

StartWin.IsBackground = false;

StartWin.Start();

}

public void DisplayIt()

{

System.Windows.Forms.Application.Run(new Form1());

}

protected override void OnStop()

{

StartWin.Abort();

}

Thanks.

Kyah




Re: Visual C# General Display a windows form in a windows services application

Peter Ritchie

It's not recommended to display a user interface in a service. You can manually configure your service to interact with the desktop; but there's some issues with automating that with .NET. As well Vista does not support it. You'd also have to deal with situations where there is no desktop (i.e. the user hasn't logged in yet).

The recommended approach is to create a separate GUI application and communicate via inter-process communication (system-wide events, named pipes, etc.).