Solved

Synchronization between applications

Posted on 1998-06-12
8
199 Views
Last Modified: 2013-11-20
I have a DLL which is being used by 2 applications. I want to synchronize the accesing of the DLL using a mutex. I
I used a CMutex object and used CSingleLock to lock and unlock the resource(DLL). It is working in the same apllication. But across applications the DLL is not getting locked. I want to know what is the reason and solution for this. Kindly help me. Is it not possible thro mutexes? Can I know that process of putting the applications in OLE out-of-process server and Yonat suggested to me?
Chensu: I have given the object name for the mutex.
The code construct is as follows:
CMutex mutObj; //in global scope
//inside my resource
CSingleLock singleLock(&mutObj);
singleLock.Lock();
{
;;;;
}
singleLock.Unlock();
The exclusion is taking place within the appln but not across the applns.

0
Comment
Question by:aac
  • 4
  • 3
8 Comments
 
LVL 5

Expert Comment

by:yonat
ID: 1317891
I think that each application loads a seperate instance of the DLL into it's own process space.

To have the same objects shared by to processes (applications), you will need to put them in an OLE out-of-process server.
0
 

Author Comment

by:aac
ID: 1317892
Edited text of question
0
 

Author Comment

by:aac
ID: 1317893
Edited text of question
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 23

Expert Comment

by:chensu
ID: 1317894
I think the CMutex object can be used across process boundaries. But you must specify the name of the CMutex object. Do you specify a name when you construct the object?
0
 

Author Comment

by:aac
ID: 1317895
Edited text of question
0
 
LVL 23

Expert Comment

by:chensu
ID: 1317896
No, you haven't given a name for the mutex. It is not the C++ object name. Use the following code.

CMutex mutObj(FALSE, _T("MyMutex"));

mutObj will reference the mutex "MyMutex". If you don't give it a name, it will create a new mutex, in which case you have two seperated mutex objects created in two processes.
0
 

Author Comment

by:aac
ID: 1317897
Chensu's answer worked out!!! Hats off to Chensu. Thank U very much for prompt answers.
0
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 1317898
So, why did you reject my answer instead of giving me A? :-(
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maven archtype selection in eclipse 1 57
either24  challenge 19 97
zeroMAx challenge 20 105
Change to event 1 115
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

831 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