Tray icon in Windows service

  • Thread starter Mats-Lennart Hansson
  • Start date
M

Mats-Lennart Hansson

Hi,
I'm having a hard time getting my service to show a sys tray icon. I've
tried to create a separate Windows application where I simply add a
notification icon to the form. In the OnStart method of the service I simply
try to start the windows application which then should show the icon.

I can't get it to work! When I run the separate Windows application the icon
turns up, but when I start it from the service it doesn't. How should I do
this?

Thanks,
Mats-Lennart
 
N

Nicholas Paldino [.NET/C# MVP]

Mats,

You should not have your service try and show a tray icon. Services, in
general, should not have a user interface. However, that doesn't mean that
you can't have a user interface that communicates with the service. The
reason for this is that you can not always be guaranteed that you will have
an active desktop session to interact with.

What you should do is provide a remoted object that can be connected to,
or use some other kind of communication between the client (which would have
the tray notification icon), and the service.

Hope this helps.
 
M

Mats-Lennart Hansson

Hi,
Thanks for answering. I understand your point but my problem remains. How do
my service communicate with the user interface program (the client)?

Regards,
Mats-Lennart


Nicholas Paldino said:
Mats,

You should not have your service try and show a tray icon. Services, in
general, should not have a user interface. However, that doesn't mean that
you can't have a user interface that communicates with the service. The
reason for this is that you can not always be guaranteed that you will have
an active desktop session to interact with.

What you should do is provide a remoted object that can be connected to,
or use some other kind of communication between the client (which would have
the tray notification icon), and the service.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Mats-Lennart Hansson said:
Hi,
I'm having a hard time getting my service to show a sys tray icon. I've
tried to create a separate Windows application where I simply add a
notification icon to the form. In the OnStart method of the service I simply
try to start the windows application which then should show the icon.

I can't get it to work! When I run the separate Windows application the icon
turns up, but when I start it from the service it doesn't. How should I do
this?

Thanks,
Mats-Lennart
 
N

Nicholas Paldino [.NET/C# MVP]

Mats,

There are a number of ways to do this. The easiest way would be to
expose an object through remoting which you could connect to through your
client application.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Mats-Lennart Hansson said:
Hi,
Thanks for answering. I understand your point but my problem remains. How do
my service communicate with the user interface program (the client)?

Regards,
Mats-Lennart


message news:ueOGR#[email protected]...
Mats,

You should not have your service try and show a tray icon.
Services,
in
general, should not have a user interface. However, that doesn't mean that
you can't have a user interface that communicates with the service. The
reason for this is that you can not always be guaranteed that you will have
an active desktop session to interact with.

What you should do is provide a remoted object that can be connected to,
or use some other kind of communication between the client (which would have
the tray notification icon), and the service.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Mats-Lennart Hansson said:
Hi,
I'm having a hard time getting my service to show a sys tray icon. I've
tried to create a separate Windows application where I simply add a
notification icon to the form. In the OnStart method of the service I simply
try to start the windows application which then should show the icon.

I can't get it to work! When I run the separate Windows application
the
icon
turns up, but when I start it from the service it doesn't. How should
I
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top