我在一个返回状态的函数中编写了以下代码。它工作正常,但现在它在Skype呼叫完成后立即设置状态。因此,状态设置为"路由"每次通话而不是"拒绝","取消","完成"我希望得到通话的最终状态。 此外,如何在调用完成之前完成其余代码。我还想获得调用的持续时间,但是现在它将它设置为零,因为下一行代码会在调用完成后立即执行。 我正在使用 Skype4COM Lib 。 这是代码:
Private Function placeSkypeCall(ByVal number As String, ByRef status As String)
Dim oSkype = skype
If Not oSkype.Client.IsRunning Then
oSkype.Client.Start()
System.Threading.Thread.Sleep(20000)
End If
''Setting Necessary Constant Variables to interact with Skype object
Dim cUserStatus_Offline = oSkype.Convert.TextToUserStatus("OFFLINE")
Dim cUserStatus_Online = oSkype.Convert.TextToUserStatus("ONLINE")
'Setting the user as online
If cUserStatus_Offline = oSkype.CurrentUserStatus Then
oSkype.ChangeUserStatus(cUserStatus_Online)
End If
'Setting an end user
Dim oUser = oSkype.User(number)
'placing the call
Dim oCall = oSkype.PlaceCall(oUser.Handle)
status = oSkype.Convert.CallStatusToText(oCall.Status)
If status.ToString() = "Finished" Then
status = "Success"
ElseIf status.ToString() = "Refused" Then
status = "Declined"
ElseIf status.ToString() = "Cancelled" Then
status = "Unanswered"
End If
Return status
End Function