[英]detect when uploadValues is completed?
将数据发布到远程php文件后,我想显示一个消息框。
PS:数据完全处理后,php文件返回字符串“ END”
if (1 == outputToGui)
{
CompressFile("allFilesList.txt");
byte[] allFilesList = File.ReadAllBytes("allFilesList.txt.gz");
string URIx = "http://example.com/post.php";
System.Collections.Specialized.NameValueCollection data = new System.Collections.Specialized.NameValueCollection();
data.Add("serial", serial);
data.Add("data", Convert.ToBase64String(allFilesList));
using (WebClient tayba = new System.Net.WebClient())
{
try
{
tayba.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
tayba.Proxy = null;
tayba.UploadValues(URIx, "POST", data);
}
catch (Exception E) { }
}
}
MessageBox.Show("upload completed"); // this message show up before the php file process the posted data sometimes.. ?!!!!
问题是消息框有时会在php文件处理所发布的数据之前显示..?!!!!
那是因为操作是异步的。 调用messagebox时,上传可能仍在进行中。
在webclient中搜索正确的完成事件,然后在其中添加您的消息。 META:_webClient.eventName + =(发送方,参数)=> MessageBox.Show(“ Ta-dah!”);
开始上传之前,请分配事件监听器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.