UploadStringCompletedEventArgs 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为 UploadStringCompleted 事件提供数据。
public ref class UploadStringCompletedEventArgs : System::ComponentModel::AsyncCompletedEventArgs
public class UploadStringCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
type UploadStringCompletedEventArgs = class
inherit AsyncCompletedEventArgs
Public Class UploadStringCompletedEventArgs
Inherits AsyncCompletedEventArgs
- 继承
示例
下面的代码示例演示如何异步上传字符串。
void UploadStringInBackground2( String^ address )
{
WebClient^ client = gcnew WebClient;
Uri ^uri = gcnew Uri(address);
String^ data = "Time = 12:00am temperature = 50";
client->UploadStringCompleted += gcnew UploadStringCompletedEventHandler( UploadStringCallback2 );
client->UploadStringAsync( uri, data );
}
public static void UploadStringInBackground2(string address)
{
WebClient client = new WebClient();
Uri uri = new Uri(address);
string data = "Time = 12:00am temperature = 50";
client.UploadStringCompleted += new UploadStringCompletedEventHandler(UploadStringCallback2);
client.UploadStringAsync(uri, data);
}
Public Shared Sub UploadStringInBackground2(ByVal address As String)
Dim client As WebClient = New WebClient()
Dim data As String = "Time = 12:00am temperature = 50"
AddHandler client.UploadStringCompleted, AddressOf UploadStringCallback2
Dim uri as Uri = New Uri(address)
client.UploadStringAsync(uri, data)
End Sub
上传完成后,将调用以下方法。
void UploadStringCallback2( Object^ /*sender*/, UploadStringCompletedEventArgs^ e )
{
String^ reply = dynamic_cast<String^>(e->Result);
Console::WriteLine( reply );
}
private static void UploadStringCallback2(Object sender, UploadStringCompletedEventArgs e)
{
string reply = (string)e.Result;
Console.WriteLine(reply);
}
Private Shared Sub UploadStringCallback2(ByVal sender As Object, ByVal e As UploadStringCompletedEventArgs)
Dim reply As String = CStr(e.Result)
Console.WriteLine(reply)
End Sub
注解
此类的实例将传递给 UploadStringCompletedEventHandler。
属性
Cancelled |
获取一个值,该值指示异步操作是否已被取消。 (继承自 AsyncCompletedEventArgs) |
Error |
获取一个值,该值指示异步操作期间发生的错误。 (继承自 AsyncCompletedEventArgs) |
Result |
获取通过调用 UploadStringAsync 方法启动的字符串上载操作的服务器回复。 |
UserState |
获取异步任务的唯一标识符。 (继承自 AsyncCompletedEventArgs) |
方法
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
GetHashCode() |
作为默认哈希函数。 (继承自 Object) |
GetType() |
获取当前实例的 Type。 (继承自 Object) |
MemberwiseClone() |
创建当前 Object 的浅表副本。 (继承自 Object) |
RaiseExceptionIfNecessary() |
如果异步操作失败,则引发用户提供的异常。 (继承自 AsyncCompletedEventArgs) |
ToString() |
返回表示当前对象的字符串。 (继承自 Object) |