/// <summary> /// Closes current session: closes session logs if all input Items were processed /// </summary> public static void Close() { lock (Log.Main) { if (This == null) { return; } if (This.closing_thread != null) { return; } State = SessionState.CLOSING; This.Storage.WriteState(State, new { }); This.closing_thread = ThreadRoutines.Start(This.close); } }
internal static void Start() { lock (threads2bot_cycle)//locked until threads2bot_cycle[t] = bc; to have a correct thread number { if (threads2bot_cycle.Count >= Settings.Engine.MaxBotThreadNumber) { return; } BotCycle bc = null; Thread t = ThreadRoutines.Start(() => { bc = Activator.Create <BotCycle>(false); bc.bot_cycle(); } ); if (!SleepRoutines.WaitForCondition(() => { return(bc != null && bc.Id >= 0); }, 100000)) { throw new Exception("Could not start BotCycle thread"); } threads2bot_cycle[t] = bc; } }