private R UserOper <R>(string operationType, Func <R> action, OutputDelegate output) { OutputDelegate prev = userTraceRedir; //lock (OnBotCreatedHooks) Action needsExit = LockInfo.MonitorTryEnter("UserOper " + operationType, BotUsers, MaxWaitTryEnter); try { userTraceRedir = output; try { return(action()); } catch (ChatSignal ex) { throw; } catch (Exception e) { writeToLog(e); if (!ChatOptions.AllowRuntimeErrors) { return(default(R)); } throw; } } finally { userTraceRedir = prev; needsExit(); } }