0

I have a simple c++ class - A which has some tasks in it.

concurrency::task<void> m_task1;

And I wanted to cancel the task in the destructor. But i can see the destructor is never executed. I am afraid this can create memory leak. Why the destructor is not executed?

class MyClass
    {
    public:
        explicit MyClass(MyException func);
        ~MyClass();
        void Start(int interval = 2000);
    private:
        concurrency::task<void> m_task;
        concurrency::cancellation_token_source m_cancellationToken;     
        ...
    };

/// <summary>Destructor.</summary>
MyClass::~MyClass()
{
  // I clean up here  
}
sohel14_cse_ju
  • 2,481
  • 9
  • 34
  • 55

0 Answers0