Platform SDK: Active Directory, ADSI, and Directory Services

Asynchronous Searches

Generally speaking, enabling asynchronous searches produces the following result: a call to GetFirstRow or the first call to GetNextRow will block until the first entry is returned from the server. This means that if the search on the server is taking a lot of time, you can get back the first few results quickly. This can help if you are, for instance, populating a list box with the search results. You can show the search results and grow the list as they come.

If async is not enabled, the first call to GetFirstRow or GetNextRow will block until the server computes the entire result set and returns. Only then is the first row returned. This is not recommended if the result set is expected to be large.

If both paging and async are enabled, GetFirstRow or GetNextRow will block until the server generates and sends the first page of results. If you have set a reasonable page size, you should start seeing results immediately. More importantly, if the search results are expected to be huge, and you are looking for a particular entry, you need not ask for more results from the server after you have found the entries that interest you.

A paged async search will give you more fine-grained control over how the search should behave. You can opt for this if the search result might be huge and the search might take a long time on the server.