private void changestate(bool state) { if (testwait.InvokeRequired)//不是同一线程调用,调用控件的委托 { ChangeStateCallback d = new ChangeStateCallback(changestate); this.Invoke(d, new object[] { state }); } else { testwait.Enabled = state; } }
/// <summary> /// Changes the state of the button as approriate, /// but supports a thread safe method of completing /// the task. /// </summary> /// <param name="IsWorking">See the 'changeState' method</param> private void changeState(bool IsWorking) { if (btnGo.InvokeRequired) { ChangeStateCallback d = new ChangeStateCallback(changeState); this.Invoke(d, new object[] { IsWorking }); } else { btnGo.Enabled = (!IsWorking); btnGo.Text = (IsWorking) ? "Working, please wait..." : "Go"; } }
public AttackPattern2(EnemyFireBall fireBall, GameTimer fireballLifeTimer, Animator animator, Transform transform, Rigidbody rigidbodyComponent, BattlePlayer targetObject, Vector3 position, float fireballSpeed, TimerCallback pushFireball, ChangeStateCallback changeStateCallback, float Power) : base(animator, rigidbodyComponent) { this.fireBall = fireBall; this.fireballLifeTimer = fireballLifeTimer; this.animator = animator; this.transform = transform; this.rigidbodyComponent = rigidbodyComponent; this.targetObject = targetObject; this.fireballSpeed = fireballSpeed; this.pushFireball = pushFireball; this.changeStateCallback = changeStateCallback; this.Power = Power; }
private static void ExecuteDelegate(ChangeStateCallback changeStateCallback) { changeStateCallback(EnemyStateType.Idle); }