how are you all
i have a problem .... and I need you to help me
I want to make my windows service appears in the taskbar when it's running
like the services appear in the taskbar like this photo
how can i do it .....
thanks for helping
maroko
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Raaj KumarPosted Mar 17, 2010, 12:37 AM
maroko marPosted Mar 16, 2010, 5:29 PM
i do it :D
thaaaaaaaaaaaaaaanx
Raaj KumarPosted Mar 16, 2010, 7:10 AM
For showing Tray Icon, windows message loop is required which is not in windows service.So to achieve this create a separate thread which will call this windows forms and and run this windows forms on it for showing the notify Icon.
public class WindowsMessageLoopThread
{
private Thread _thread = null;
private AutoResetEvent _startedEvent = new AutoResetEvent(false);
private Form1 _form = null;
public WindowsMessageLoopThread()
{
_thread = new Thread(new ThreadStart(ThreadFunction));
_thread.Start();
_startedEvent.WaitOne();
}
public void Stop()
{
_form.BeginInvoke(new MethodInvoker(_form.Close));
_thread.Join();
}
private void ThreadFunction()
{
_startedEvent.Set();
_form = new Form1();
System.Windows.Forms.Application.Run(_form);
}
}
Finally in change the Installer Account Type to LocalSystem.
RightClick MyComputer-->Manage-->Services And Application-->Services--> Select your service (which is displayed in right hand side)--->Right Click on the service--->Properties--->LogOn(TabItem)---> Check Allow Service to interact with desktop
Regards,
raaj