DoWork()関数で、sipサーバーに登録します。それから私は返事を待たなければなりません。しかし、私が得た応答は別のイベントで受信されます。ただし、DoWork()でフラグを確認する前に、DoWork()はすべて完了し、応答が後に表示されます。
Diagnoticイベントで応答を受け取るまで、DoWork()で待機する方法を見つけようとしています。DoWork()でチェックする必要があるイベントで設定されるグローバルフラグがあります。
アドバイスありがとうございます、
// Do work in background worker
//Will return less than 8 if there are no error message from the library
if (!this.bgwProcessLogin.CancellationPending)
{
// Register and wait for response
VaxSIPUserAgentOCX.RegisterToProxy(3600);
}
else
{
// Update label
if (this.lblRegistering.InvokeRequired)
{
// do something here
}
else
{
// Display error
}
}
// WAIT FOR A RESPONSE FROM THE DIAGNOTIC EVENT BEFORE CONTINUING - MAYBE JOIN HERE
if (!this.bgwProcessLogin.CancellationPending)
{
if (this.responseFlag)
{
// Do something here
}
else
{
// Do something else here
}
}
// Another function where I receive the response
private void VaxSIPUserAgentOCX_OnIncomingDiagnostic(object sender, AxVAXSIPUSERAGENTOCXLib._DVaxSIPUserAgentOCXEvents_OnIncomingDiagnosticEvent e)
{
string messageSip = e.msgSIP;
//Find this message in the sip header
string sipErrorCode = "600 User Found";
if (messageSip.Contains(sipErrorCode))
{
// Set global flag for response
this.responseFlag = true;
}
}