From: Stupid488 on
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 ...
From: Patrice on
Hello,

> I left out some of
> 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

But w2cDrv.Device.[Call] seems to be a non blocking call else you wouldn't
need Console.ReadKey to pause the application. So I don't see for now how
threading could help (or do you inted to check the line status continuously
in a background thread ?)...

As you seems to have several events available, my first thought is that you
should have an event such as OnCallDisconnected or something similar ? It
seems more a product issue. Have you checked the SDK ? (tried but gave up as
it needs a registration).

Finally, I would suggest to immediately switch to a WinForm application as a
Console app is not well suited to handling events and can be tricky...
--
Patrice



From: Patrice on
> You are correct, there are events like OnCallDisconnect that fire.
> The issue is, I don't know how to resubmit the w2cDrv.Device.[Call]
> in the winform app once the OnCallDisconnect fires...
>
> Basically, when the disconnect happens and some variable is True, I
> want to redial immediately....

To get something to start with what happens if you just put
w2cDrv.Device.Call in the OnCallDisconnect event handler ?

For now I don't get what is the issue you have with just calling whatever
you want when OnCallDisconnect fires. Or is it that you are new with event
driven programming ?

--
Patrice





 | 
Pages: 1
Prev: Shortcut target
Next: Help for populate Chart