OpenReadCompletedEventHandler Delegate
.NET Framework 4.5
Represents the method that will handle the OpenReadCompleted event of a WebClient.
Namespace: System.Net
Assembly: System (in System.dll)
public delegate void OpenReadCompletedEventHandler( Object sender, OpenReadCompletedEventArgs e )
Parameters
- sender
- Type: System.Object
The source of the event.
- e
- Type: System.Net.OpenReadCompletedEventArgs
A OpenReadCompletedEventArgs containing event data.
The following code example demonstrates downloading a resource for reading.
The following method is called when the download completes.
private static void OpenReadCallback2 (Object sender, OpenReadCompletedEventArgs e)
{
Stream reply = null;
StreamReader s = null;
try
{
reply = (Stream)e.Result;
s = new StreamReader (reply);
Console.WriteLine (s.ReadToEnd ());
}
finally
{
if (s != null)
{
s.Close ();
}
if (reply != null)
{
reply.Close ();
}
}
}
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.