Dart.PowerTCP.EmailValidation Namespace : DnsEventArgs Class |
Provides data for any event that marks the completion of asynchronous host name, IP address, or mail address resolution.
For a list of all members of this type, see DnsEventArgs members.
System.Object
System.EventArgs
Dart.PowerTCP.EmailValidation.DnsEventArgs
[Visual Basic]
Public Class DnsEventArgs
Inherits EventArgs
[C#]
public class DnsEventArgs : EventArgs
[C++]
public __gc class DnsEventArgs : public EventArgs
[C++/CLI]
public ref class DnsEventArgs : public EventArgs
A DnsEventArgs object is passed as a parameter to all events that mark the completion of asynchronous host name, IP address, or mail address resolution. If a host name or IP address was resolved using Dns.BeginGetHost, the DnsEventArgs.Host property would contain a System.Net.IPHostEntry object containing data about the resolved host name/IP address. If an email address was resolved using Dns.BeginGetMailHosts, the DnsEventArgs.Hosts property would contain an array of System.Net.IPHostEntry objects each containing data about the resolved email address.
If your code causes an exception, it would be returned to the handling event without you seeing it. To preclude such a condition, you should ALWAYS use a try/ catch block around your event-handling code.
The following example demonstrates using the Dns control to asynchronously resolve a domain name.
[Visual Basic]
Private Sub AsynchResolveTest()
Dns1.Server = "206.64.128.5"
Dns1.BeginGetHost("www.dart.com", Nothing)
End Sub
Private Sub Dns1_EndGetHost(ByVal sender As Object, ByVal e As DnsEventArgs) Handles Dns1.EndGetHost
' Check for any exceptions that occurred
If e.Exception Is Nothing Then
DisplayResult(e.Host)
End If
End Sub
Private Sub DisplayResult(ByVal result As System.Net.IPHostEntry)
' Display host name
Debug.WriteLine("Host name: " + result.HostName)
' Display addresses, if any
Dim add As System.Net.IPAddress
For Each add In result.AddressList
Debug.WriteLine("Address: " + add.ToString())
Next
' Display aliases, if any
Dim s As String
For Each s In result.Aliases
Debug.WriteLine("Aliases: " + s)
Next
End Sub
[C#]
private void AsynchResolveTest()
{
dns1.Server = "206.64.128.5";
dns1.BeginGetHost("www.dart.com", null);
}
private void dns1_EndGetHost(object
sender, DnsEventArgs e)
{
// Check for any exceptions that occurred
if(e.Exception == null)
{
DisplayResult(e.Host);
}
}
private void DisplayResult(System.Net.IPHostEntry result)
{
// Display host name
Debug.WriteLine("Host name: " + result.HostName);
// Display addresses, if any
foreach(System.Net.IPAddress add in result.AddressList)
Debug.WriteLine("Address: " + add.ToString());
// Display aliases, if any
foreach(string s in result.Aliases)
Debug.WriteLine("Aliases: " + s);
}
Namespace: Dart.PowerTCP.EmailValidation
Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista
Assembly: Dart.PowerTCP.EmailValidation (in Dart.PowerTCP.EmailValidation.dll)
DnsEventArgs Members | Dart.PowerTCP.EmailValidation Namespace
Send comments on this topic.
Documentation version 1.0.3.0.
© 2008 Dart Communications. All rights reserved.