private void changeState(bool ativo) { // Caso a thread principal esteja usando o botão, ele invoca o delegado para que ele seja alterado if (this.button_parar.InvokeRequired) { object[] args = new object[] { ativo }; changeStateDelegate changeState_Delegate = changeEnabled; this.Invoke(changeState_Delegate, args); } // Caso contrário, apenas muda o botão else { changeEnabled(ativo); } }
private void changeState(string newLabel) { // Caso a thread principal esteja usando o botão, ele invoca o delegado para que ele seja alterado if (this.button_update.InvokeRequired) { object[] args = new object[] { newLabel }; changeStateDelegate changeState_Delegate = changeLabel; this.Invoke(changeState_Delegate, args); } // Caso contrário, apenas muda o botão else { changeLabel(newLabel); } }