我正在建立一个通过呼叫服务器(星号)接受呼叫并触发事件的系统
_manager.NewState += new NewStateEventHandler(manager_NewStateEvent);
AsteriskManager.cs
以下是manager_NewStateEvent
:
private void manager_NewStateEvent(object sender, NewStateEvent e)
{
managerState = e.ChannelStateDesc;
if (OnPhoneStateChange != null)
OnPhoneStateChange(e);
Console.WriteLine("New State : " + e.ChannelStateDesc);
switch (e.ChannelStateDesc)
{
case "Down":
case "OffHook":
case "Dialing":
case "Ring":
case "Ringing":
case "Up":
case "Busy":
break;
}
}
Form1.cs的
void _manager_OnPhoneStateChange(Asterisk.NET.Manager.Event.NewStateEvent e)
{
StateLabel.Text = e.ChannelStateDesc;
this.Refresh();
}
_manager.NewState
是呼叫进入时被调用的事件。然后在我的C#表单中,我试图根据我得到的响应更改标签,但标签没有更新。
(我试图通过点击按钮强制方法_manager_OnPhoneStateChange
,它工作正常)