Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 192193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:24:19+00:00 2026-05-11T16:24:19+00:00

In my DoWork() function I register with our sip server. Then I have to

  • 0

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().

Thanks for any advice,

// 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;
        }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:24:20+00:00Added an answer on May 11, 2026 at 4:24 pm

    You could use a ManualResetEvent. Once your code hits the the WaitOne call, it will block until the event is Set. The WaitOne call is also overloaded so you can provide a duration to wait if you need to.

    void SomeFunction()
    {
    // 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
    
            waitEvent.WaitOne();
            if (!this.bgwProcessLogin.CancellationPending)
            {
                if (this.responseFlag)
                {
                    // Do something here   
                }
                else
                {
                    // Do something else here
                }
            }
    }
    
    ManualResetEvent waitEvent = new ManualResetEvent(false);
    
    // 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;
                waitEvent.Set();
            }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

am trying to get my head around the following: Have a small program am
I have a function running over an enumerable, but the function should be a
I have created a function for a thread, but I want to pass multiple
I've got a particular function I want to run once, and only after the
I'm trying to create a chain of function calls using two objects. I've added
What I have is a loop reading some data and when a set of
I have a background worker that's checking the status of four services on a
I already read the man page of the pidfile function family. But I don't
Is it possible to use HTMl.RenderAction using ajax to provide the parameter? I have
For my customer I occasionally do work in their live database in order to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.