471,306 Members | 1,345 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

Only one instance of an application

I know one varient of this question has been posted a lot, but this
seems to be slighlty different.

I've got the following code in my application

<code>

[STAThread]
private static void Main()
{
bool createdNew;
string process_name =
Process.GetCurrentProcess().ProcessName.ToString() ;
Mutex m = new Mutex(true, process_name, out createdNew);
if (!createdNew)
{
return;
}
Application.Run(new Form1());

GC.KeepAlive(m);
}
</code>

whilst this works fine for a user logged onto a machine, it does NOT
work across multiple RDP connections.

Is it possible to detect if another user has already started an
application in another session? Or would I be better moving the entire
application into a service (its an order processing application) and
just displaying the GUI of the application to the user who attempts to
'start' the application?

Dec 1 '05 #1
1 1366
Code Monkey wrote:
I know one varient of this question has been posted a lot, but this
seems to be slighlty different.
<snip>
whilst this works fine for a user logged onto a machine, it does NOT
work across multiple RDP connections.

Is it possible to detect if another user has already started an
application in another session? Or would I be better moving the entire
application into a service (its an order processing application) and
just displaying the GUI of the application to the user who attempts to
'start' the application?


I believe it depends on the name of the mutex. If you name the mutex
"Global\[...]" then I *believe* it should work. It's then scoped for
the whole machine, rather than that particular login.

Jon

Dec 1 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Dmitry Karneyev | last post: by
8 posts views Thread by Li Pang | last post: by
8 posts views Thread by Jon Weston | last post: by
6 posts views Thread by perera | last post: by
20 posts views Thread by Boki Digtal | last post: by
2 posts views Thread by Jassim Rahma | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.