本文介绍了如何在线程中转换此代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void OnCallStateChanged(object sender, CallStateEventArgs e)
{
if (this.InvokeRequired)
{
EventHandler<callstateeventargs> eh = OnCallStateChanged;
this.BeginInvoke(eh, new object[] { sender, e });
return;
}
TapiLine line = (TapiLine)sender;
TapiCall call = e.Call;
foreach (ListViewItem lvi in lst_call_Monitoring.Items)
{
if (lvi.Tag == call)
{
lvi.SubItems[COLUMNS_STATE].Text = call.CallState.ToString();
if (GetActiveCall() == call)
AdjustButtonState(call);
if (call.CallState == CallState.Idle)
{
call.Dispose();
lst_call_Monitoring.Items.Remove(lvi);
}
else if (call.CallState.ToString() == "Ringing")
{
lvi.BackColor = Color.DarkBlue;
}
else if (call.CallState.ToString() == "Ringback")
{
lvi.BackColor = Color.DarkOrange;
}
else if (call.CallState.ToString() == "Dialtone")
{
lvi.BackColor = Color.DarkRed;
}
else if (call.CallState.ToString() == "Offering")
{
lvi.BackColor = Color.DarkOrange;
}
else if (call.CallState.ToString() == "Connected")
{
lvi.BackColor = Color.DimGray;
stopwatch.Start();
Thread.Sleep(1);
lvi.SubItems[8].Text = stopwatch.Elapsed.ToString();
}
else if (call.CallState.ToString() == "Disconnected")
{
lvi.BackColor = Color.DarkRed;
stopwatch.Stop();
lvi.SubItems[8].Text = stopwatch.Elapsed.ToString();
}
}
}
推荐答案
这篇关于如何在线程中转换此代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!