OpenWriteCompletedEventArgs Kelas
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menyediakan data untuk peristiwa tersebut OpenWriteCompleted .
public ref class OpenWriteCompletedEventArgs : System::ComponentModel::AsyncCompletedEventArgs
public class OpenWriteCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
type OpenWriteCompletedEventArgs = class
inherit AsyncCompletedEventArgs
Public Class OpenWriteCompletedEventArgs
Inherits AsyncCompletedEventArgs
- Warisan
Contoh
Contoh kode berikut menunjukkan pembukaan aliran untuk menulis data yang akan diunggah.
void OpenResourceForPosting( String^ address )
{
WebClient^ client = gcnew WebClient;
Uri ^uri = gcnew Uri(address);
// Specify that the OpenWriteCallback method gets called
// when the writeable stream is available.
client->OpenWriteCompleted += gcnew OpenWriteCompletedEventHandler( OpenWriteCallback2 );
client->OpenWriteAsync( uri );
// Applications can perform other tasks
// while waiting for the upload to complete.
}
public static void OpenResourceForPosting(string address)
{
WebClient client = new WebClient();
Uri uri = new Uri(address);
// Specify that the OpenWriteCallback method gets called
// when the writeable stream is available.
client.OpenWriteCompleted += new OpenWriteCompletedEventHandler(OpenWriteCallback2);
client.OpenWriteAsync(uri);
// Applications can perform other tasks
// while waiting for the upload to complete.
}
Public Shared Sub OpenResourceForPosting(ByVal address As String)
Dim client As WebClient = New WebClient()
' Specify that the OpenWriteCallback method gets called
' when the writeable stream is available.
AddHandler client.OpenWriteCompleted, AddressOf OpenWriteCallback2
Dim uri as Uri = New Uri(address)
client.OpenWriteAsync(uri)
' Applications can perform other tasks
' while waiting for the upload to complete.
End Sub
Metode berikut dipanggil saat aliran tersedia.
void OpenWriteCallback2( Object^ /*sender*/, OpenWriteCompletedEventArgs^ e )
{
Stream^ body = nullptr;
StreamWriter^ s = nullptr;
try
{
body = dynamic_cast<Stream^>(e->Result);
s = gcnew StreamWriter( body );
s->AutoFlush = true;
s->Write( "This is content data to be sent to the server." );
}
finally
{
if ( s != nullptr )
{
s->Close();
}
if ( body != nullptr )
{
body->Close();
}
}
}
private static void OpenWriteCallback2(Object sender, OpenWriteCompletedEventArgs e)
{
Stream body = null;
StreamWriter s = null;
try
{
body = (Stream)e.Result;
s = new StreamWriter(body);
s.AutoFlush = true;
s.Write("This is content data to be sent to the server.");
}
finally
{
if (s != null)
{
s.Close();
}
if (body != null)
{
body.Close();
}
}
}
Private Shared Sub OpenWriteCallback2(ByVal sender As Object, ByVal e As OpenWriteCompletedEventArgs)
Dim body As Stream = Nothing
Dim s As StreamWriter = Nothing
Try
body = CType(e.Result, Stream)
s = New StreamWriter(body)
s.AutoFlush = True
s.Write("This is content data to be sent to the server.")
Finally
If Not s Is Nothing Then
s.Close()
End If
If Not body Is Nothing Then
body.Close()
End If
End Try
End Sub
Keterangan
Instans kelas ini diteruskan ke OpenWriteCompletedEventHandler metode.
Properti
Cancelled |
Mendapatkan nilai yang menunjukkan apakah operasi asinkron telah dibatalkan. (Diperoleh dari AsyncCompletedEventArgs) |
Error |
Mendapatkan nilai yang menunjukkan kesalahan mana yang terjadi selama operasi asinkron. (Diperoleh dari AsyncCompletedEventArgs) |
Result |
Mendapatkan aliran bisa-tulis yang digunakan untuk mengirim data ke server. |
UserState |
Mendapatkan pengidentifikasi unik untuk tugas asinkron. (Diperoleh dari AsyncCompletedEventArgs) |
Metode
Equals(Object) |
Menentukan apakah objek yang ditentukan sama dengan objek saat ini. (Diperoleh dari Object) |
GetHashCode() |
Berfungsi sebagai fungsi hash default. (Diperoleh dari Object) |
GetType() |
Mendapatkan instans Type saat ini. (Diperoleh dari Object) |
MemberwiseClone() |
Membuat salinan dangkal dari yang saat ini Object. (Diperoleh dari Object) |
RaiseExceptionIfNecessary() |
Meningkatkan pengecualian yang disediakan pengguna jika operasi asinkron gagal. (Diperoleh dari AsyncCompletedEventArgs) |
ToString() |
Mengembalikan string yang mewakili objek saat ini. (Diperoleh dari Object) |