Solved

synchronizing

Posted on 1998-10-27
2
210 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add content to output file 4 67
Sed question 2 102
"Black Box" Testing of Control System Software 2 70
Bartender label printing - switch on and off graphics 3 54
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

860 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