Solved

synchronizing

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Running shell command from Access 3 63
ShiftLeft challenge 21 66
Thin secure Windows 10 5 48
Making an alias 7 52
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

20 Experts available now in Live!

Get 1:1 Help Now