Dismiss Notice
We would like to remind you that we’re updating our login process for all 3CX forums whereby you will be able to login with the same credentials you use for the Partner or Customer Portal. Click here to read more.

Do .Net function calls run asynchronously from the main flow

Discussion in 'CRM / Helpdesk / App Integration' started by njfrost, Sep 29, 2012.

Thread Status:
Not open for further replies.
  1. njfrost

    Joined:
    Aug 13, 2012
    Messages:
    22
    Likes Received:
    0
    I'm asking this to better understand how the VAD makes .Net function calls, rather than to solve a particular problem.

    In order to illustrate the point, I have a test .Net function which sleeps for a number of milliseconds then returns (see below).
    My main flow is 5 voice prompts alternating with 5 calls to my .Net function to pause 2 seconds each time.

    You would expect there to be a 2 second gap between each voice prompt,
    but what actually happens is that a single ten second delay (5 x 2 sec) occurs before the 5 voice prompts, which then execute contiguously. Then the call ends.

    Can someone please explain how this behaviour is happening?
    Thanks

    Code:
            // sets a pause in millisec
            public string IvrPause(string ms)
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                Thread.Sleep(int.parse(ms);
                sw.Stop();
                DebugToFile("stopwatch", string.Format("{0:000000}", sw.ElapsedMilliseconds)); // just to prove it!
                return "OK";
            }
    
     

    Attached Files:

  2. VAD_Support

    VAD_Support Active Member

    Joined:
    Aug 6, 2009
    Messages:
    690
    Likes Received:
    0
    Re: Do .Net function calls run asynchronously from the main

    Hi,

    .NET functions are called synchronously. If you need to perform an async operation, you can launch a new thread to do the job.

    What is happening here is that your prompt playback components are set with AllowBargeIn=True. When that property is set to true, all the messages are queued until an input is needed or the call ends. So, here all the wav files are played at the end, after 10 seconds. If you set the AllowBargeIn property to False, then you will see that each wav file is played after 2 seconds. But in this case if you have a menu or user input component later, DTMF digits will not interrupt your messages.

    Regards,
     
  3. njfrost

    Joined:
    Aug 13, 2012
    Messages:
    22
    Likes Received:
    0
    Re: Do .Net function calls run asynchronously from the main

    Thanks for the info. It's very helpful.
     
Thread Status:
Not open for further replies.