15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


MFC CSingleLock.Lock() Broken???

Erik van der Goot -- erik.van-der-goot@jrc.it
Tuesday, February 27, 1996

NT3.51 VC++4.0 MFC

I ran into problems using CEvent and CSingleLock. Declare a CEvent* pEvent
in one thread. In the constructor do a pEvent=new CEvent(). Pass the pointer
to a second thread. Do a CSingleLock sLock(pEvent) on this and now try to
lock it. sLock.Lock(). This thread now waits for a pEvent->Setevent() in the
other thread. Works. 

Now the reverse. Somewhere I want to test for an event, not wait for it. So
I try using sLock.IsLocked(). No joy. So I try sLock.Lock(0). No joy. So I
think I've got it wrong somewhere else and waste a day. 

In the end I reverse my logic and create this particular event
signalled/manual. In my loop I now try to lock it. Works (not surprising,
see above). So to stop looping I do a pEvent->ResetEvent(); (And yes, I do
test the return value..)
Now the Lock hangs. This is correct. However. If I now change the Lock() to
Lock(0), it should immediately return and tell me it can't do the lock. Well,
it returns but it does not return FALSE.... 

So I guess this is a bug..

Anybody??

Thanks very much

Erik




Mike Blaszczak -- mikeblas@msn.com
Friday, March 01, 1996

----------
From: 	owner-mfc-l@netcom.com on behalf of Erik van der Goot
Sent: 	Tuesday, February 27, 1996 10:37

> So I guess this is a bug..
> Anybody??
> Thanks very much

As I posted in the mfc newsgroup, indeed it is a bug and it has been fixed for 
MFC 4.1.

.B ekiM
TCHAR szBosstones[] = _T("I'm all out of answers, don't even search me.");





| Вернуться в корень Архива |