取消上传任务
Cancelling an upload task
我已经阅读了一些关于Azure SDK的阅读,为了取消一个任务,你似乎需要传递一个cancellation_token
。
我的上传代码非常简单:
azure::storage::cloud_block_blob blockBlob = container.get_block_blob_reference(fileLeaf.wstring());
auto task = blockBlob.upload_from_file_async(fullFilePath);
但是,我上传的某些文件可能非常大,我希望能够取消此操作。 如果可能的话,我可能还会使用延续,并且也需要所有这些取消。
我遇到的问题是我看不到任何将cancellation_token
附加到任务的方法。
有什么指示吗?
有一个
使用 PPL 库的示例代码,我参考了它并更改了使用 REST SDK 中的 PPLX 库取消任务的代码C++该代码用于 Azure 存储 SDK,用于C++,请尝试以下代码。
/* Declare a cancellation_token_source and get the cancellation_token,
* please see http://microsoft.github.io/cpprestsdk/classpplx_1_1cancellation__token__source.html
*/
#include <pplxtasks.h>
cancellation_token_source cts;
auto token = cts.get_token();
//Pass the cancellation_toke to task via then method, please see https://msdn.microsoft.com/en-us/library/jj987787.aspx
task.then([]{}, token).wait();
// Cancel the task
cts.cancel();
希望对您有所帮助。
相关文章:
- 挂起和取消挂起一个文件DLL
- 如何取消对nullptr的屏蔽,返回正确的对象
- C++取消引用指针.为什么会发生变化
- 使用取消引用的指针的多态性会产生意外的结果.为什么?
- 取消引用运算符不能重载
- 在他自己的方法中,有可能将一个对象取消引用到另一个对象吗
- 如何在Qt中取消捕获字符串
- 有没有任务栏API可以立即应用注册表更改
- 如何使用 TStyleManager::UnRegisterStyle() 取消注册样式
- GLEW/GLUT:调用init并创建一个窗口后,取消初始化并重新初始化?
- C++ 关于指针取消引用的技术问题
- 取消上传任务
- 在将函数分配给函数指针时,为什么可以多次使用取消任务运算符
- 取消一个c++11异步任务
- 当任务所有者被销毁时,取消挂起的任务回调调用
- 使自动隐藏的任务栏在窗口上可见,最大化而不取消隐藏
- 如何在 boost::asio 线程池中使任务可取消/可中断
- 尝试使用while循环取消分配向量,任务管理器显示内存使用正在增加
- 取消libclang任务
- Pthread_cond_timedwait()用于取消长时间任务