This topic is now archived and is closed to further replies.


How to cancel the host enumeration process properly?

Recommended Posts

Ok, here I go again... As SDK states, that to enumerate a host, in case of peer2peer case, use the funtion as follows. I did, it work. Fine, no problems.
	if( !FAILED( hr = m_pDP->EnumHosts(&dpAppDesc,             // pApplicationDesc m_pHostAddress,         // pdpaddrHost m_pDeviceAddress,       // pdpaddrDeviceInfo NULL, 0,                // pvUserEnumData, size 4,                      // dwEnumCount 0,                      // dwRetryInterval 0,                      // dwTimeOut NULL,                   // pvUserContext m_pAsyncHandle,         // pAsyncHandle DPNENUMHOSTS_SYNC) ) )  // dwFlags

But, as u can see that, there is a DPNENUMHOSTS_SYNC, in the last paramter. So, the operation get sync and if it takes longer time, then the peer enumerating, must have to wait, until it completes. Now, I wanted to change it, like to cancel the request, if the user want. Then SDK states that use CancelAsyncOperation(...), to cancel the operation. Now, since I''m new to directplay, I would like to ask a couple of questions about that. How to make this EnumHost(...) run asynchronously, like I only find 3 possible flags for the the last paramter, but none of them told me how to run it asynchronously. I tried this, CancelAsyncOpertion(...) with EnumHost(...), along with the DPNENUMHOSTS_SYNC flag in it, it worked, but then it showed another wiered behaviour. Like, if I cancel the the enumeration process, then when I try to close the application, it just froze, no errors, nothing, just froze, when I debug, then I found that the control goes to the IDirectplay8Peer::Close(), but after that, it just stuck there. Any help in this matter will be highly appricated and thanx in advance. Regards, Ejaz.

Share this post

Link to post
Share on other sites