Print Page | Close Window

Waiting for call to complete and then redialing?

Printed From: Way2call Communications
Category: Hi-Phone Software Development Kit (SDK)
Forum Name: Hi-Phone and .NET
Forum Description: Discussion on the Hi-Phone product family, its .NET interface, samples and development tools
URL: http://www.way2call.com/forum/forum_posts.asp?TID=61
Printed Date: Apr 19 2024 at 7:05am


Topic: Waiting for call to complete and then redialing?
Posted By: stupid48
Subject: Waiting for call to complete and then redialing?
Date Posted: Apr 01 2010 at 7:39pm
I'm writing a .net executable that will dial out.  If nobody answers, inside the same running application, I would like to redial.  The problem is, I don't know how to pause and wait for the first call to finish.  In the sample console application, there is a "goto" loop that allows the redial and the key to the loop is the line:

cki = Console.ReadKey(false);

So, the Console.ReadKey is pausing the thread while the software is dialing and waiting for someone to hit "a" to make a new call.  Does anyone know how to pause the thread in a windows .net application?
 
Thanks....Chris



Replies:
Posted By: mattj
Date Posted: Apr 20 2010 at 11:51am
I'm just a noob so there's probably a better method but i created a class. I have a few global vars to track different events.

Imports Way2call
Imports Way2call.Driver
Imports System.Threading
Public Class Cls_Events
    Public Sub WaitForConnection(ByVal DurationSec As Integer, ByVal DeviceID As Integer)
        MyCallDropped = False   'clear dropped call flag
        MyCallBusy = False      'clear number busy flag
        MyCallErrored = False   'clear call error flag
        MyCallConnected = False 'clear call connected flag

        Static start_time As DateTime = Now
        Dim elapsed_time As TimeSpan

        Do
            If MyCallConnected = True Then Exit Do 'exit loop if OnConnected event is fired
            If MyCallBusy = True Then Exit Do 'exit loop if the line is busy
            If MyCallDropped = True Then Exit Do 'exit loop if the call was dropped
            elapsed_time = Now.Subtract(start_time)
           
            ' operation timed out exit the loop
            If elapsed_time.TotalSeconds >= DurationSec Then Exit Do
            Application.DoEvents()
        Loop
    End Sub
End Class



then i did something like:

w2cErr = w2cDrv.Device(0).Call("w5558675309", True, True)
Dim CallEvent As New Cls_Events
CallEvent.WaitForConnection(40, 0)







Print Page | Close Window