locked
Destructor not running when using AsyncActionCompletedHandler RRS feed

  • Question

  • Consider the following code in C++/CX:

        std::shared_ptr<int> a(new int(9));
            
        int cnt = a.use_count(); // == 1
    
        {
            auto ppp = ref new AsyncActionCompletedHandler(
                [a](IAsyncAction^ asyncInfo)
                {        
                });
    
            cnt = a.use_count(); // == 2
        }    
        
        cnt = a.use_count(); // still == 2 !!!
    


    Is this a bug ?

    Note that it's C++/CX, no GC here, so 'ppp' is destroyed on scope exit, however, 'a's destructor not run...

    Thursday, January 26, 2012 12:42 PM

All replies

  • Would someone from MS tell me whether it's a bug or not please and how to work around it...
    Friday, January 27, 2012 2:52 PM