Hello,
C# 2008 SP1
The function below will be called from another thread. So the control themselves will have to be invoked so that the correct thread that created them can change the properties.
However, as I have many controls that need to be updated. I don't really want to write all those delegates for each one. I have done one below. However, I am thinking that is a lot of code. Is there anyway to shorten this?
Many thanks,
public void SetIdleState(string callStatusMsg)
{
this.btnCallAnswer.Text = CATWinSIP_MsgStrings.Call;
this.btnEndCallReject.Text = CATWinSIP_MsgStrings.EndCall;
this.btnHoldUnhold.Text = CATWinSIP_MsgStrings.Hold;
this.btnCallAnswer.Enabled = true;
this.btnRedial.Enabled = true;
this.btnEndCallReject.Enabled = false;
this.btnHoldUnhold.Enabled = false;
if (this.statusDisplay1.InvokeRequired)
{
statusDisplay1.Invoke(new UpdateCallStatusDelegate(this.UpdateCallStatus), callStatusMsg);
}
else
{
this.statusDisplay1.CallStatus = callStatusMsg;
}
}
// Delegate for marshalling the call on the correct thread.
private delegate void UpdateCallStatusDelegate(string callStatusMsg);
private void UpdateCallStatus(string callStatusMsg)
{
this.statusDisplay1.CallStatus = callStatusMsg;
}