我有一个独立的桌面WPF C#应用程序,带有一个帮助按钮,可以向我的服务台发起Skype电话呼叫。如果服务台终止通话,一切正常。但是,如果客户(应用程序用户)终止呼叫,则应用程序将挂起。我通过搜索许多网络资源将以下代码拼凑在一起。
private void btnSkype_Click(object sender, EventArgs e)
{
Skype oSkype = new Skype();
if (!oSkype.Client.IsRunning) {
oSkype.Client.Start(false, false); //minimized, no splash
}
try {
oSkype.Attach(5, true); //wait for client to be connected and ready
}
catch (Exception ex) {
MessageBox.Show("Exception: " + ex.Message);
}
Call oCall = oSkype.PlaceCall("SRGWJG");
do
{
System.Threading.Thread.Sleep(1);
} while (oCall.Status != TCallStatus.clsInProgress);
oSkype.Client.Focus();
oCall.StartVideoSend();
do
{
System.Threading.Thread.Sleep(1);
} while (oCall.Status == TCallStatus.clsInProgress);
oSkype.Client.Minimize();
}