而且WaitForMultipleObjects有这么一说 The function modifies the state of some types of synchronization objects. Modification occurs only for the object or objects whose signaled state caused the function to return. For example, the count of a semaphore object is decreased by one. When bWaitAll is FALSE, and multiple objects are in the signaled state, the function chooses one of the objects to satisfy the wait; the states of the objects not selected are unaffected.大意是: 多个内核对象被触发时,WaitForMultipleObjects选择其中序号最小的返回。而waitForMultipleObjects它只会改变使它返回的那个内核对象的状态。如果序号最小的那个对象频繁被触发,那么序号比它大的内核对象将得不到被处理的机会。
int n=WAIT_OBJECT_0-1;
if(res >n)
pOggFile->ProcessBuffer();
n的值为-1,res的值在0-9之间,就是被一直跳过~
int n=WAIT_OBJECT_0;
if(res-1>n)
pOggFile->ProcessBuffer();
ReleaseMutex( pOggFile->m_hSingleAcessDirectSoundBuffer8);
就正常了但是我现在调试就是看不到res等于1的值,res可以是0,2,3,4,5,6,7,8,9,我代码就改了刚才那几个地方,VS2008真是绝了,求高人提供一个比VS2008好用的IDE,我只要平台SDK开发就行了,不需要其他胡里花俏的功能
我用VS2008到现在,发现过不止一次的BUG,难道其他人就没遇到BUG?
我代码从BUG出现到BUG结束就改了刚才的那几个语句,又没指针之类的,难道会影响到其他地方?
int n=WAIT_OBJECT_0-1;
if(res >n) n=0x00000000 - 1
n=0xFFFFFFFF
无符号数的话,条件永远不会成立。
编译器一般会有提示 warning C4018: '>' : signed/unsigned mismatch
DWORD a = 0;
int b = -1;
ASSERT( a > b);
这个很对,基础很扎实呀,楼主看编译输出窗口中是不是针对你的这句代码有个Warning在C#里,任何数据都必须显式的强制转换才能使用,否则无法通过编译。
if(res >n) res是无符号型,n是有符号型,在这里n会被当成0xffffffff也就是4294967295,
而不是你认为的-1。
The function modifies the state of some types of synchronization objects. Modification occurs only for the object or objects whose signaled state caused the function to return. For example, the count of a semaphore object is decreased by one. When bWaitAll is FALSE, and multiple objects are in the signaled state, the function chooses one of the objects to satisfy the wait; the states of the objects not selected are unaffected.大意是:
多个内核对象被触发时,WaitForMultipleObjects选择其中序号最小的返回。而waitForMultipleObjects它只会改变使它返回的那个内核对象的状态。如果序号最小的那个对象频繁被触发,那么序号比它大的内核对象将得不到被处理的机会。