WebClient回调函数传递参数
使用WebClient类下载数据,具体代码如下:
问题是,回调函数的格式只能是void DownloadDataCallback(Object^ sender, DownloadDataCompletedEventArgs^ e),那我怎么才能把我的dataTemp参数传递给回调函数呢?
先谢过了!
void DownloadDataInBackground(String^ address, String^ dataTemp)
{
try
{
WebClient^ client = gcnew WebClient;
client->BaseAddress = address;
client->DownloadDataCompleted += gcnew DownloadDataCompletedEventHandler(DownloadDataCallback);
client->DownloadDataAsync(gcnew Uri(address));
}
catch(...)
{
Console::WriteLine("{0} download failed!", address);
}
}其中,address是下载地址,dataTemp是我要传递的数据。问题是,回调函数的格式只能是void DownloadDataCallback(Object^ sender, DownloadDataCompletedEventArgs^ e),那我怎么才能把我的dataTemp参数传递给回调函数呢?
先谢过了!
...全文


VC.NET
