What is the problem inside my work, I tried to use a UI Thread.
private void btn_Call_Click(object sender, EventArgs e)
{
MakeCall();
}
private void MakeCall()
{
try
{
//Get the IP we want to call.
otherPartyIP = new IPEndPoint(IPAddress.Parse(txtCallToIP.Text), 1450);
otherPartyEP = (EndPoint)otherPartyIP;
//Get the vocoder to be used.
if (cmbCodecs.SelectedText == "A-Law")
{
vocoder = Vocoder.ALaw;
}
else if (cmbCodecs.SelectedText == "u-Law")
{
vocoder = Vocoder.uLaw;
}
else if (cmbCodecs.SelectedText == "None")
{
vocoder = Vocoder.None;
}
//Send an invite message.
SendMessage(Command.Invite, otherPartyEP);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "VoiceChat-Call ()", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
That returns the error:
Cross-thread operation not valid: Control ‘btn_Call’ accessed from a thread other than the thread it was created on