When you use an AsyncCallback delegate to process the results of the asynchronous operation in a separate thread, you can use a state object to pass information between the callbacks and to retrieve a final result.
demonstrates using asynchronous methods in the Dns class to retrieve Domain Name System (DNS) information for user-specified computers.
uses the HostRequest class to store state information.
A HostRequest object gets created for each computer name entered by the user.
This object is passed to the BeginGetHostByName method.
The ProcessDnsInformation method is called each time a request completes.
The HostRequest object is retrieved using the AsyncState property.
The ProcessDnsInformation method uses the HostRequest object to store the IPHostEntry returned by the request or a SocketException thrown by the request.
a state object that holds each requested host name,
an associated IPHostEntry object or a SocketException.
AsyncCallback callBack = new AsyncCallback(ProcessDnsInformation);
HostRequest request = new HostRequest(host);
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.