Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 从不同线程调用方法_.net_Multithreading - Fatal编程技术网

.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)
{
    //
}