S
Stupid488
I've got this simple console application that came with a phone dialer
and a DLL. The basic part of the code is below. I left out some of
the initial parts and also the event handlers that occur when certain
events happen while it's dialing(ie. OnCallConnected, OnDTMF_KeyDown
(someone hits a key on the phone)). What I would like to do is call
the dialer (w2cDrv.Device.[Call]) and wait for the call to complete
and then possibly re-dial on certain occasions (ie some variable is
True). The problem is, I don't know how to wait for the dialing to
finish. The code below uses cki = Console.ReadKey(False) which
basically has the console window wait for someone to hit a key in that
window to redial. While it is waiting, it does not interrupt the
dialing and interaction with the phone callee but just waits for a
user to hit a key in the console. How can I wait for the call to
finish without needing someone to actually hit a key in the console
window without interfering with the call? Somehow I think threading
but it's new to me...Also, I really plan on using a forms app instead
of a console otherwise I have to worry about message pumping on top of
this thread issue...but that's for another time...
Thanks for any pointers you can give...
Chris
Code sample:
reenternumber:
'User enters phone number to dial here and it get stored in variable
"w". Left code out for simplicity
'then we call the device to dial here. This actually dials the
number.....
Dim xError As CWay2callDriver.Errors = DirectCast(w2cDrv.Device.[Call]
("w" + sNumber, True, True), CWay2callDriver.Errors)
' handle errors ...
If xError <> CWay2callDriver.Errors.SUCCESS Then
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("Call(..) Method returned error: " +
xError.ToString() + " " & vbLf)
Console.ForegroundColor = cc
w2cDrv.Device.HangUp(False)
MyHangUpCall = 0
MyCallConnected = 0
Console.WriteLine(sLogo)
GoTo renternumber
End If
' wait key press ...
Console.WriteLine("Calling " + sNumber + ", Press any key to
end, 'a' for another call." & vbLf)
'this is where it waits for user to hit key and this is where i would
want to pause
cki = Console.ReadKey(False)
If cki.KeyChar = "a"c Then
w2cDrv.Device.HangUp(False)
MyHangUpCall = 0
MyCallConnected = 0
Console.Clear()
Console.WriteLine(sLogo)
GoTo renternumber
End If
mainend:
iErr = w2cDrv.Device.Close(0)
'close the device
' handle errors ...
iErr = w2cDrv.ShutdownDriver(0)
'must be last called
' handle errors ...
and a DLL. The basic part of the code is below. I left out some of
the initial parts and also the event handlers that occur when certain
events happen while it's dialing(ie. OnCallConnected, OnDTMF_KeyDown
(someone hits a key on the phone)). What I would like to do is call
the dialer (w2cDrv.Device.[Call]) and wait for the call to complete
and then possibly re-dial on certain occasions (ie some variable is
True). The problem is, I don't know how to wait for the dialing to
finish. The code below uses cki = Console.ReadKey(False) which
basically has the console window wait for someone to hit a key in that
window to redial. While it is waiting, it does not interrupt the
dialing and interaction with the phone callee but just waits for a
user to hit a key in the console. How can I wait for the call to
finish without needing someone to actually hit a key in the console
window without interfering with the call? Somehow I think threading
but it's new to me...Also, I really plan on using a forms app instead
of a console otherwise I have to worry about message pumping on top of
this thread issue...but that's for another time...
Thanks for any pointers you can give...
Chris
Code sample:
reenternumber:
'User enters phone number to dial here and it get stored in variable
"w". Left code out for simplicity
'then we call the device to dial here. This actually dials the
number.....
Dim xError As CWay2callDriver.Errors = DirectCast(w2cDrv.Device.[Call]
("w" + sNumber, True, True), CWay2callDriver.Errors)
' handle errors ...
If xError <> CWay2callDriver.Errors.SUCCESS Then
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("Call(..) Method returned error: " +
xError.ToString() + " " & vbLf)
Console.ForegroundColor = cc
w2cDrv.Device.HangUp(False)
MyHangUpCall = 0
MyCallConnected = 0
Console.WriteLine(sLogo)
GoTo renternumber
End If
' wait key press ...
Console.WriteLine("Calling " + sNumber + ", Press any key to
end, 'a' for another call." & vbLf)
'this is where it waits for user to hit key and this is where i would
want to pause
cki = Console.ReadKey(False)
If cki.KeyChar = "a"c Then
w2cDrv.Device.HangUp(False)
MyHangUpCall = 0
MyCallConnected = 0
Console.Clear()
Console.WriteLine(sLogo)
GoTo renternumber
End If
mainend:
iErr = w2cDrv.Device.Close(0)
'close the device
' handle errors ...
iErr = w2cDrv.ShutdownDriver(0)
'must be last called
' handle errors ...