I have two worker threads, where one thread(WriteBuf) is writing into buffer and another thread(ReadBuf) is reading from the same buffer.
I have created CriticalSection object like CCriticalSection m_crit created globaly.
My thread code looks like below
UINT WriteBuf(LPVOID pParam)
buf = 'a'; //Writing to buffer.
UINT ReadBuf(LPVOID pParam)
buf1 = buf; Reading from the buffer.
Please let me know is this the rite way to lock the resource(buffer),coz i havent unlocked yet but still i can able to read the buffer from another thread(ReadBuf) .
So please help me to understand the critical section usage here.