Quote Originally Posted by new_2012 View Post
The problem was , the code was functioning fine on WIN XP ,
Which means it doesn't function "fine". You are just lucky that right now, things seem to run fine on XP.

Distribute that application to hundreds or thousands of customers who run XP in different ways, different setups, different background processes running, different hardware, etc. and you would more than likely see that something is wrong (one or more customer will report a crash or inconsistent behaviour with your application).
Now , yesterdat it self , I put proper Locks and Unlocks to protect Data and things seem to be ok.
Your code may still have problems, as Arjay pointed out.

First, mutexes are used across processes, not critical sections.

Second, even if you use a mutex, this is an issue:
Code:
crdll.Lock();
if (data of type 1) process data;
crdll.Unlock();
What if "process data" throws an exception? You now have a lock that was never unlocked since it never got to the "crdll.Unlock" line of code. Please see the CSingleLock class, since you're using MFC. The CSingleLock class is an example of an RAII object.

The destructor of CSingleLock is called whenever it goes out of scope for any reason whatsoever. This means that multiple return points, exceptions being thrown, etc. are all going to unlock the handle.

http://msdn.microsoft.com/en-US/libr...=vs.80%29.aspx
After use of the resource is complete, either call the Unlock function if the CSingleLock object is to be used again, or allow the CSingleLock object to be destroyed.
Regards,

Paul McKenzie