Solved

synchronizing

Posted on 1998-10-27
2
208 Views
Last Modified: 2013-11-20
hi, regards!
I am using VC++ Document file called coninfo.rec to store
some configuration information. i used cmapstringtoob classes to serialzie information. I am using 2 different threads in my application. I had a function which access this document information. Those 2 threads may access this function. In order to avoid this function been called by a thread when other  one is using it, please help me how to synchronize. Will the critical section methods apply ?

the function name is Proccess_Query(.....)

the to other thread routines that calls this function is
threadfunc1(....) & threadfunc2(...)

Kindly give the detailed reply. I can increase the points
for convincing answers.

thanks!
r sundar r
0
Comment
Question by:sunraj
  • 2
2 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 150 total points
ID: 1323931
In you function that both can call do this

{
LPCRITICAL_SECTION lpCriticalSection;

EnterCriticalSection(&lpCriticalSection);

// Do your stuff here

LeaveCriticalSection(&lpCriticalSection);
}

If one thread is already in the critical section the other will wait until it leaves it before entering.

Cheers,

Raymond.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1323932
Sunraj,

I just realised that lpCriticalSection is already a pointer. You will need to change the declaration so that it is a critical section structure rather than a pointer.

Cheers,

Raymond.
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

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 55
How to create frequencies of a variable from SAS dataset? 10 121
repeatEnd java challenge 42 84
Change to event 1 101
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

16 Experts available now in Live!

Get 1:1 Help Now