private bool RunGuard(Action action)
{
if (IsRunning) {
return false;
}
// save the value, restore it aftwards
var tmp = currentLoop;
IsRunning = true;
currentLoop = this;
if (action != null) {
action();
}
IsRunning = false;
currentLoop = tmp;
return true;
}