Inter-process communication

  • Thread starter Thread starter Stephen Inkpen
  • Start date Start date
S

Stephen Inkpen

Hello,

I need a way to increment an integer whenever a certain process starts
on the computer. Essentially, the integer is an index to a resource
and I don't want two processes using the same resource.

I need the first process to start somesort of a registration thing and
then every other process after that will register and get a new index.
It needs to be as lightweight as possible so remoting is out. I also
don't want to use the registry or some file stored on the computer. Is
there anything more elegant than those previous answers?

Thanks,

Stephen Inkpen
stephen.inkpen@**SPAM**cathexis.ca
 
Stephen Inkpen said:
I need a way to increment an integer whenever a certain process starts
on the computer. Essentially, the integer is an index to a resource
and I don't want two processes using the same resource.

I need the first process to start somesort of a registration thing and
then every other process after that will register and get a new index.
It needs to be as lightweight as possible so remoting is out. I also
don't want to use the registry or some file stored on the computer. Is
there anything more elegant than those previous answers?

I'd suggest using a simple port - you initially try to listen on a
port, and if that fails you try to connect to the port to get your
index.
 
You said you don't want to use the registry, but you didn't say why. It's
the first thing that came to mind since you can do it with one line of code...

Depending on your other requirements, you could consider using the Mutex
class. The constructor that takes a String param works across processes.
 
Back
Top