none
Cancelling an upload in C++ Storage SDK

    Question

  • Hi

    What's the recommended way of cancelling an upload/continuation using the SDK? I can see a lot of references to cancellation tokens but can't see how to pass one in to e.g. cloud_block_blob::upload_from_file_async()

    Thanks,

    Dave

    Tuesday, April 11, 2017 1:18 PM

Answers

  • This is answered here, if anyone else is tearing their hair out:

    http://stackoverflow.com/questions/43349656/cancelling-an-upload-task/43364311#43364311

    • Marked as answer by -dave-f- Wednesday, April 12, 2017 12:37 PM
    Wednesday, April 12, 2017 12:37 PM

All replies

  • There is a sample code using PPL library, This code will help you in  canceling task using PPLX library within C++ REST SDK which be used for Azure Storage SDK for C++, please try the code below.

    /* 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();
    

    If you still find any difficulties; Let me know

    Wednesday, April 12, 2017 9:43 AM
    Moderator
  • This is answered here, if anyone else is tearing their hair out:

    http://stackoverflow.com/questions/43349656/cancelling-an-upload-task/43364311#43364311

    • Marked as answer by -dave-f- Wednesday, April 12, 2017 12:37 PM
    Wednesday, April 12, 2017 12:37 PM