Suppose I create a thread like this:
void Function()
{
// Do stuff
// How do I delete the current thread? I have tried RAII, but it throws.
// delete backgroundThread; // Can't do this, even in finalizer
}
backgroundThread = new std::thread(&Test::Function);
How can I delete backgroundThread
? I can't use thread.join from where I create the background thread because that will block the UI.