Prevent initialization code from being called while plugin is scanned?

If you have some things that you do on creation/initialization, that you would like to NOT do when being scanned, is there anyway to determine this?

What I’ve done for now to prevent code from being executed while being scanned is to wrap the code in Timer::callAfterDelay which will apparently not be executed while scanning since the object is deleted before it can execute…

Timer::callAfterDelay (100, [this] {
                // code here will not be executed while scanning

But is there a better way?

We do something similar, putting that code in our timer callback inside the Processor component (with a flag that tells whether that code has executed once or not yet).