You can do it indirectly, by safe-guarding your IO-processes with a special flag so know, what is running.
Meta-code:
bool ioGlobalFlag = false;
ioGlobalFlag = true;
....
ioGlobalFlag = false;
Consider doing it all in a seperate thread, but than you need locking or a mutex.