How can I check te::SamplerPlugin whether a loaded audiofile is ready?

I have trouble updating my component with a waveform thumbnail after loading a new audio file into te::SamplerPlugin. I don’t know how to check that the new file is ready.

loadButton.onClick = [this]
{
    EngineHelpers::browseForAudioFile ( [this] (const File& f)
    {
       if (sampler)
       {
           if(f.existsAsFile())
           {
               DBG("New File: " + f.getFullPathName());

               sampler->setSoundMedia (soundIndex, f.getFullPathName());
               sampler->setSoundName (soundIndex, f.getFileNameWithoutExtension());
               
               juce::URL audioFileURL = juce::URL (sampler->getSoundFile(soundIndex).getFile());
               DBG("Check new file: " + audioFileURL.getFileName());
           }
       }
    });
};

The result is:

New File: /aPathToFile/TheNewFile.wav
Check new file: TheOldFile.wav

I guess this happens because behind the scenes the work is done asynchronously:

void SamplerPlugin::setSoundMedia (int index, const String& source)
{
    auto v = getSound (index);
    v.setProperty (IDs::source, source, getUndoManager());
    triggerAsyncUpdate();
}

Is there a easy way to check when the update is complete?

Probably the easiest way is to add a SelectableListener and respond to the selectableObjectChanged callback which is trigged at the end of the SamplerPlugin::handleAsyncUpdate by the changed() call.