异步上传文件的方法:
public async void UploadScreenshot(DateTime? date = null)
{
var uploadTask = Task.Factory.StartNew(() => _ftp.UploadFile(_screenshotLocalFile,
date.HasValue
? _screenshotRemoteFile.Replace("{1}", date.Value.ToString(Helper.StandardTimeFile))
: _screenshotRemoteFile.Replace("{1}", DateTime.Now.ToString(Helper.StandardTimeFile))));
await uploadTask;
}
用法:
UploadScreenshot();
这是异步上传文件的有效方法吗?