Solved

Question about Windows messaging and this Mutex example

Posted on 2010-08-20
6
289 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

13 Experts available now in Live!

Get 1:1 Help Now