public static void WaitForSearchFolderPopulation(IXSOFactory xsoFactory, IMailboxSession mailboxSession, ISearchFolder searchFolder) { if (ContactsSearchFolderCriteria.IsSearchFolderPopulated(searchFolder)) { ContactsSearchFolderCriteria.Tracer.TraceDebug((long)mailboxSession.GetHashCode(), "Search folder is already populated. No wait required."); return; } ContactsSearchFolderCriteria.Tracer.TraceDebug((long)mailboxSession.GetHashCode(), "Waiting for search folder to complete current population."); searchFolder.Load(); using (SearchFolderAsyncSearch searchFolderAsyncSearch = new SearchFolderAsyncSearch((MailboxSession)mailboxSession, searchFolder.Id.ObjectId, null, null)) { if (ContactsSearchFolderCriteria.IsSearchFolderPopulated(searchFolder)) { ContactsSearchFolderCriteria.Tracer.TraceDebug((long)mailboxSession.GetHashCode(), "Search folder population completed."); } else { bool arg = searchFolderAsyncSearch.AsyncResult.AsyncWaitHandle.WaitOne(ContactsSearchFolderCriteria.SearchInProgressTimeout); ContactsSearchFolderCriteria.Tracer.TraceDebug <bool>((long)mailboxSession.GetHashCode(), "Done waiting, search folder population completed: {0}.", arg); } } }
internal SearchFolderAsyncResult(SearchFolderAsyncSearch searchFolderAsyncSearch) { this.searchFolderAsyncSearch = searchFolderAsyncSearch; }