Hello,
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,
Code:Public Sub SetIdleState(ByVal callStatusMsg As String) Me.btnCallAnswer.Text = CATWinSIP_MsgStrings.Call Me.btnEndCallReject.Text = CATWinSIP_MsgStrings.EndCall Me.btnHoldUnhold.Text = CATWinSIP_MsgStrings.Hold Me.btnCallAnswer.Enabled = True Me.btnRedial.Enabled = True Me.btnEndCallReject.Enabled = False Me.btnHoldUnhold.Enabled = False If Me.statusDisplay1.InvokeRequired Then statusDisplay1.Invoke(New UpdateCallStatusDelegate(AddressOf Me.UpdateCallStatus), callStatusMsg) Else Me.statusDisplay1.CallStatus = callStatusMsg End If End Sub ' Delegate for marshalling the call on the correct thread. Private Delegate Sub UpdateCallStatusDelegate(ByVal callStatusMsg As String) Private Sub UpdateCallStatus(ByVal callStatusMsg As String) Me.statusDisplay1.CallStatus = callStatusMsg End Sub




Reply With Quote