Solved

Question about Windows messaging and this Mutex example

Posted on 2010-08-20
6
324 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
Technology Partners: 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!

 
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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

627 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