Archived

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

Ejaz

How to cancel the 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. [edited by - Ejaz on August 6, 2003 2:58:29 AM]

Share this post


Link to post
Share on other sites
> 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.

Have you tried 0 ?

> {...} control goes to the IDirectplay8Peer::Close(), but
> after that, it just stuck there.

m_pDP->CancelAsyncOperation( NULL, DPNCANCEL_ALL_OPERATIONS );
m_pDP->Close( 0 );
SAFE_RELEASE( m_pDP );

-cb

Share this post


Link to post
Share on other sites
thanx cbenoi1,

It seems like, whenever I got stuck somewhere, u always wander somewhere around me and get me out of the mess.

The solution you mentioned works, like if I don''t close the connection right after the cancelation of the enumeration process, then the application got froze, but if I close it and again re-initlize it next time, then everything works fine.

Anyways, thanx for the help man, u r a life saver.

Regards,

Ejaz.

Share this post


Link to post
Share on other sites