The following example demonstrates querying Address records asynchronously using the static
method called GetAddressRecordsAsync(). When the method has finished executing,
the call back method RetrieveAddressRecord() will be called.
[C#]
using System;
using aspNetDns;
using aspNetDns.Records;
namespace consoleTest
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string LookupRecord = "microsoft.com";
AddressRecord.GetAddressRecordsAsync( LookupRecord, new ARecordDelegate( RetrieveAddressRecord) );
}
private static void RetrieveAddressRecord(AddressRecord[] records)
{
if( records.Length > 0 )
{
foreach( AddressRecord r in records )
Console.WriteLine( r.IP.ToString() );
}
else
Console.WriteLine( "No records were found.");
Console.ReadLine();
}
}
}
[VB.NET]
Imports aspNetDns
Imports aspNetDns.Records
Module Module1
Sub Main()
Dim LookupRecord As String = "microsoft.com"
AddressRecord.GetAddressRecordsAsync(LookupRecord, New ARecordDelegate(AddressOf RetrieveAddressRecord))
End Sub
Private Sub RetrieveAddressRecord(ByVal records() As AddressRecord)
If records.Length > 0 Then
Dim r As AddressRecord
For Each r In records
Console.WriteLine(r.IP.ToString())
Next r
Else
Console.WriteLine("No records were found.")
End If
Console.ReadLine()
End Sub
End Module