Solved

Question about Windows messaging and this Mutex example

Posted on 2010-08-20
6
297 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
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now