Hello,

In my DoWork() function I register with our sip server. Then I have to wait for a response back. However, the response I get is received in another event. However, before I am able to check the flag in the DoWork() the DoWork() has all ready finished and the response comes after.

I am trying to find a way to wait in the DoWork() until I get a response in the Diagnotic event. I have a global flag that is set in that event that I have to check in the DoWork().

I was thinking of maybe blocking in the DoWork() until the other event is finished. Maybe using a join. However, I am not sure that this is the best solution.

Thanks for any advice,

Code:
' Do work in background worker
'Will return less than 8 if there are no error message from the library 
		If (Not Me.bgwProcessLogin.CancellationPending) Then
				' Register and wait for response
				VaxSIPUserAgentOCX.RegisterToProxy(3600)
		Else
				' Update label
				If Me.lblRegistering.InvokeRequired Then
				  ' do something here
				Else
					' Display error
				End If
		End If

' WAIT FOR A RESPONSE FROM THE DIAGNOTIC EVENT BEFORE CONTINUING - MAYBE JOIN HERE
		If (Not Me.bgwProcessLogin.CancellationPending) Then
			If Me.responseFlag Then
				' Do something here   
			Else
				' Do something else here
			End If
		End If


' Another function where I receive the response
private void VaxSIPUserAgentOCX_OnIncomingDiagnostic(Object sender, AxVAXSIPUSERAGENTOCXLib._DVaxSIPUserAgentOCXEvents_OnIncomingDiagnosticEvent e)
		Dim messageSip As String = e.msgSIP
		'Find this message in the sip header

		Dim sipErrorCode As String = "600 User Found"
		If messageSip.Contains(sipErrorCode) Then
			' Set global flag for response
			Me.responseFlag = True
		End If