Do .Net function calls run asynchronously from the main flow

Status
Not open for further replies.

njfrost

Joined
Aug 13, 2012
Messages
22
Reaction score
1
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";
        }
 

Attachments

  • pause.PNG
    pause.PNG
    36.6 KB · Views: 2,506
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,
 
Re: Do .Net function calls run asynchronously from the main

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

Forum statistics

Threads
112,322
Messages
591,882
Members
165,467
Latest member
EMMEPICASA