/** * When a RestartState finishes its task, this is the * EventHandler that is called. * * At the end of a RestartState, we call StartAttempt for * the TA we are waiting on. If we have restarted too many * times, we move to the next TA, and StartAttempt with that one. */ protected void RestartHandler(object orss, EventArgs args) { RestartState rss = (RestartState)orss; BC.TaskWorker next_task = StartAttempt(rss.TA); if (next_task == null) { //Looks like it's time to move on: next_task = StartAttempt(NextTA()); } if (next_task != null) { _task_queue.Enqueue(next_task); } }
public static void Initialize(Scene scene) { Scene = scene; menuState = new MenuState(); settingState = new SettingState(); aboutState = new AboutState(); overwriteState = new OverwriteState(); gameState = new PlayState(); pauseState = new PauseState(); restartState = new RestartState(); winningState = new WinningState(); winAllState = new WinAllState(); exitGameState = new ExitGameState(); exitAppState = new ExitAppState(); InitializeGame(); }
/** * Given a TransportAddress, return the associated RestartState. * If there are no more restarts, this returns null. */ protected RestartState GetRestartState(TransportAddress ta) { RestartState rss = null; lock ( _ta_to_restart_state ) { rss = (RestartState)_ta_to_restart_state[ta]; if (rss == null) { //This is the first time we are restarting rss = new RestartState(this, ta); } else if (rss.RemainingAttempts > 0) { //We have to decrement the remainingAttempts: int ra = rss.RemainingAttempts - 1; rss = new RestartState(this, ta, ra); } else { /* * The old TA has had it */ rss = null; } } if (rss != null) { _ta_to_restart_state[rss.TA] = rss; rss.FinishEvent += this.RestartHandler; #if LINK_DEBUG if (BU.ProtocolLog.LinkDebug.Enabled) { BU.ProtocolLog.Write(BU.ProtocolLog.LinkDebug, String.Format("{0}: Linker({1}) restarting; remaining attempts: {2}", _local_n.Address, _lid, rss.RemainingAttempts)); } #endif } return(rss); }
/** * Given a TransportAddress, return the associated RestartState. * If there are no more restarts, this returns null. */ protected RestartState GetRestartState(TransportAddress ta) { RestartState rss = null; lock( _ta_to_restart_state ) { rss = (RestartState)_ta_to_restart_state[ta]; if( rss == null ) { //This is the first time we are restarting rss = new RestartState(this, ta); } else if (rss.RemainingAttempts > 0) { //We have to decrement the remainingAttempts: int ra = rss.RemainingAttempts - 1; rss = new RestartState(this, ta, ra); } else { /* * The old TA has had it */ rss = null; } } if( rss != null ) { _ta_to_restart_state[rss.TA] = rss; rss.FinishEvent += this.RestartHandler; #if LINK_DEBUG if (ProtocolLog.LinkDebug.Enabled) { ProtocolLog.Write(ProtocolLog.LinkDebug, String.Format("{0}: Linker({1}) restarting; remaining attempts: {2}", _local_n.Address, _lid, rss.RemainingAttempts)); } #endif } return rss; }