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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Raaj KumarRank #7,836 · 233 reputationPosted Mar 16, 2010, 3:10 AM EDT
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
maroko mar3 reputationPosted Mar 16, 2010, 1:29 PM EDT
i do it :D
thaaaaaaaaaaaaaaanx
Raaj KumarRank #7,836 · 233 reputationPosted Mar 16, 2010, 8:37 PM EDT