/////////////////////////////////////////////////////////////////////// public void Leave(string pilot) { // NOTE: See "Callback Dispatch Comments" for explanation of the dispatch pattern and why it is needed. // Bundle up the arguments. LeaveRequest_DispatchDelegateArgs args = new LeaveRequest_DispatchDelegateArgs(pilot); // Delegate the work such that the UI thread of the game_stage calls the XXX_Dispatch() method // to do the actual work. _game_stage.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new LeaveRequest_DispatchDelegate(LeaveRequest_Dispatch), this, new object[] { args }); }
private void LeaveRequest_Dispatch(object sender, LeaveRequest_DispatchDelegateArgs args) { string trace_msg = "Leave request: from: " + args.pilot; Trace.WriteLine(trace_msg); PilotControllerInfo pilot_info = null; pilot_dictionary.TryGetValue(args.pilot, out pilot_info); if (pilot_info != null) { string msg = "Controller removing pilot: " + args.pilot; Trace.WriteLine(msg); PlayerJetRemoveFromStage(pilot_info.actor); // Remove from stage (and sprite update loop). pilot_dictionary.Remove(args.pilot); // Removed from pilot dictionary. } else { string msg = "!!! Controller could not find pilot: " + args.pilot; Trace.WriteLine(msg); } }