DirectorySearcher.Asynchronous Property

Definition

Gets or sets a value that indicates if the search is performed asynchronously.

C#
public bool Asynchronous { get; set; }
C#
[System.DirectoryServices.DSDescription("DSAsynchronous")]
[System.Runtime.InteropServices.ComVisible(false)]
public bool Asynchronous { get; set; }

Property Value

true if the search is asynchronous; false otherwise.

Attributes

Examples

The following C# example shows how to create an asynchronous search.

C#
using System.DirectoryServices;  
...  
// Bind to the users container.  
DirectoryEntry entry = new DirectoryEntry("LDAP://CN=users,DC=fabrikam,DC=com");  
// Create a DirectorySearcher object.  
DirectorySearcher src = new DirectorySearcher(entry);  
//Set the Asynchronous property to true.  
src.Asynchronous = true;  
//Use the FindAll method to get search results.  
SearchResultCollection res = src.FindAll();  

Remarks

An asynchronous search can show results as they are found while simultaneously searching for additional results. This is useful for tasks such as populating list boxes.

The default setting for this property is false.

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9