Connecting Tech Pros Worldwide Forums | Help | Site Map

System Tray - Service - Communication

Newbie
 
Join Date: Oct 2008
Posts: 7
#1: May 15 '09
Hi there,

we are creating some automated backup solution for some user application (let's say "UserApp" ;)). Now, the backup service is working perfectly.

But there's a problem: the backups cannot be created if some user is working with the "UserApp" at the same time, because of locked files, etc. So the service should be able to tell the user to close the application and wait until the user does.

As I already know that a service shouldn't (and since Vista: CANNOT) communicate with the user "directly", I thought of a system tray icon where the user also could see whether the service is running.

Now I also partly created such a tray app and it is working well so far.

My big problem is now, that I don't have a clue about creating a client-service-communication. As said, I want the service to send some sort of message to the system tray application, which then perhaps translates that message and informs the user with a ballon tip for example.

Is there a simple way to achieve this?
How would you going to do this?
Which sort of communication would you use? IPC? Pipes? Sockets?

I have read many articles and threads about this topic, but I couldn't find any proper solution and/or how to implement that.

Thanks in advance for helping me ;)

Greetings

Lawyno

Newbie
 
Join Date: Oct 2008
Posts: 7
#2: May 19 '09

re: System Tray - Service - Communication


Is there really no one, who can help me?
I really need a solution very soon and I'm stuck with this one :(
PRR PRR is offline
Moderator
 
Join Date: Dec 2007
Location: India
Posts: 701
#3: May 19 '09

re: System Tray - Service - Communication


You could use Named Pipes... You can also look into WCF...
A simple approach would be write to a file (in a specified folder) and have your windows form app watch it... Read from file and display the status ... Just make sure your win form app has rights to read the file ...
Newbie
 
Join Date: Oct 2008
Posts: 7
#4: May 19 '09

re: System Tray - Service - Communication


Quote:

Originally Posted by DeepBlue View Post

You could use Named Pipes... You can also look into WCF...
A simple approach would be write to a file (in a specified folder) and have your windows form app watch it... Read from file and display the status ... Just make sure your win form app has rights to read the file ...

Thx for the reply ;)

I also thought of named pipes. But how do I implement named pipes in C# (or .NET)?

I've read those msdn articles, but they are written for C++ and it seems to me that those methods are not available for C#.

Perhaps I'm searching with the wrong words, but I didn't find any (good) articles/tutorials about implementing named pipes in C# (or .NET).

So can you (or somebody else) please tell me how to do this?

Thank you & have a nice day ;)

Lawyno
PRR PRR is offline
Moderator
 
Join Date: Dec 2007
Location: India
Posts: 701
#5: May 19 '09

re: System Tray - Service - Communication


Check this article by Peter Bromberg...
Newbie
 
Join Date: Oct 2008
Posts: 7
#6: May 26 '09

re: System Tray - Service - Communication


Well I somehow managed to get it to work with IPC in the meantime. :)

Working myself through that complicated C#-Named-Pipes-With-Native-Methods-Wrapper-Stuff would have been too much overhead, compared to my (simple) solution.

Thanx anyway ;)

Lawyno
Reply