473,588 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.GetCurr entProcess().Pr ocessName.ToStr ing();
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 1434
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3490
by: Vikrant | last post by:
Friends, Due an application (old) install program problem, Under AIX I could only create DB2 instance, I could also catalog it. Its complex application and I am not expert in creating full database for this application, but I have desired DB2 backup (by db2 backup db command). Can I do redirected restore (SET TABLESPACE CONTAINERS ....) only when instance is created & cataloged , I am under the impression that redirected restore is...
6
4652
by: Dmitry Karneyev | last post by:
Hi! I guess this question have been asked a lot of times, but please be tolerant and if you have any ideas share it. The question is: how to make availibale only one instance of application and if second one is loaded it must be close and give focus to first one. Thanks for any advice! Dmitry
7
2910
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the database into classes, which are used throughout the application. I have made class collections which, upon reading from the DB, create an instance of the class and store the DB values in there temporarily. My problem is that if user1 looks at...
8
1657
by: Li Pang | last post by:
Hi I want to run my app only one instance, i.e. only one session is allowed to display Thank
6
9482
by: Xenio | last post by:
Hi, I'd like to make sure that only one instance of my app is running per User Session. In addition this has to work with user rights and in a Windows 2k/2k3 and Citrix Terminalserver environment. The code I'm using prevents the app from creating a second instance on a TS. What do I have to change?
8
3292
by: Jon Weston | last post by:
I'm setting up an Access2003 database with pictures. I put a bound ole picture ctrl on a form that's source is the table that contains the pictures and follow ALL the directions for embedding a picture. The ctrl in the form only displays the filename of the picture. The underlying table, when opened in table view, shows the word "package" in the field. When I double-click on either it opens the picture, but I can't get it to display. ...
9
2804
by: cendrizzi | last post by:
Hi all, I've read some stuff on this but can't seem to come up with a solution that works right. I have a semi-mature (yet very large and robust) internal web application that currently only works with one window open at a time. Maybe I'm abusing the use of $_SESSION but I have data entry processes split up in several steps (which is required since depending on what was put before determines what pages will be shown after). To store...
6
5514
by: perera | last post by:
I want to create a MFC program *.exe. My reguirement is at a time only one instance can be run. In Other on mutile instnces can be run at a time
20
10614
by: Boki Digtal | last post by:
Hi All, How to limit the c# program can only run one instance at the same time ? Thank you! Best regards, Boki.
2
1636
by: Jassim Rahma | last post by:
how can i make sure only one instance of my application is running and activate the running instance if the user tried to execute another instance?
0
7929
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8357
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
5729
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2372
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1459
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.