• ### Popular Now

• 13
• 15
• 27
• 9
• 9

#### Archived

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

# How to cancel the enumeration process properly?

This topic is 5337 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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

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 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 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.