.net 从不同线程调用方法
我通过以下方法将文件异步上载到服务器:.net 从不同线程调用方法,.net,multithreading,.net,Multithreading,我通过以下方法将文件异步上载到服务器: public static void uploadFile(String filePath) { ///.. some code here System.Threading.Tasks.Task<Google.Apis.Upload.IUploadProgress> task = insertRequest.UploadAsync(); task.ContinueWith(t => { /
public static void uploadFile(String filePath)
{
///.. some code here
System.Threading.Tasks.Task<Google.Apis.Upload.IUploadProgress> task = insertRequest.UploadAsync();
task.ContinueWith(t =>
{
//.. t.Result.BytesSent(); returns number of bytes sent to the server
uploadStream.Dispose();
});
timer1.Start();
}
每一秒?!你确定?!!!?但无论如何,您只需从tick事件调用方法:uploadFile(这里是params)。如果您像正常调用一样调用它,它会失败吗?我不明白为什么你能写一个线程上传方法,然后你不能调用它…@Ahmed ilyas,我想实现上传文件的进度条,这就是为什么我想每秒调用它的原因。对不起,怎么了?
private void timer1_Tick(object sender, EventArgs e)
{
//
}