Solved

Question about Windows messaging and this Mutex example

Posted on 2010-08-20
6
319 Views
Last Modified: 2012-05-10
In this demo shown here:

http://sanity-free.org/143/csharp_dotnet_single_instance_application.html

the program uses a Mutex to prevent multiple instance from opening.  It uses Windows messaging.  Does the first instance send a message and the second instance read that message, then exits?

If so where does the first instance remove that message upon exit?

Does it use the GUID to identify the message?

newbieweb
0
Comment
Question by:newbieweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Author Comment

by:newbieweb
ID: 33484807
I see this line removed the lock after completion of execution.

mutex.ReleaseMutex();
 
0
 
LVL 8

Accepted Solution

by:
mac-will earned 500 total points
ID: 33485121
There is a system Mutex. The first thing the app does is check if this Mutex is available (i.e. no other app is running)
The GUID is simply the string name of the named Mutex.

The second thing it does is broadcast a custom windows message to all windows.  The running application see's this custom message and brings itself on top of all the other windows.

The GUID has nothing to do with the Windows message.

MAC
0
 
LVL 2

Expert Comment

by:vimalalex
ID: 33485134
Hi newbieweb,
                     Are you looking to restrict your application by one instance.

Thanks & Regards,
Vimal
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 2

Expert Comment

by:vimalalex
ID: 33485266
Hi newbieweb,
         Go through this link this may help u
http://www.codeproject.com/KB/cs/singleinstance.aspx

Thanks & Regards,
Vimal
0
 

Author Comment

by:newbieweb
ID: 33485889
I am specifically trying to understand this demo so I can understand usiong a Mutex.  I am not trying to make my program run a single instance.  It does that using System.Diagnostics.Process and I am okay with that.
0
 

Author Closing Comment

by:newbieweb
ID: 33485893
Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question