private void OnClickRunButton(object sender, EventArgs e) { if (sess.Machine.IsRunning) { // stop machine thread without using Thread.Abort. // we should never Abort machine execution thread because it may corrupt the VM. runCancelToken.Cancel(); } else { runCancelToken.Reset(); StartMachineRun(); } }
/// <summary> /// Called once a "player" logs /// in to the server. /// (This does not start a new thread, so /// if you want to do any long temn functions /// please start your own thread!) /// </summary> /// <param name="player"></param> /// <returns></returns> public PluginResponse OnStart(IPlayer player) { //Check if bot settings are valid. if (!player.settings.loadWorld) { Console.WriteLine("[AntNest] 'Load world' must be enabled."); return(new PluginResponse(false, "'Load world' must be enabled.")); } stopToken.Reset(); // Attempt to join the nest. this.Role = Nest.JoinNest(player); // Hook events. player.events.onDisconnected += EventDisconnected; player.events.onTick += Tick; return(new PluginResponse(true)); }