473,500 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pausing an application waiting for a thread to finish...

1 New Member
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.....
Expand|Select|Wrap|Line Numbers
  1. Dim xError As CWay2callDriver.Errors = DirectCast(w2cDrv.Device.[Call]
  2. ("w" + sNumber, True, True), CWay2callDriver.Errors)
  3.         ' handle errors ...
  4.         If xError <> CWay2callDriver.Errors.SUCCESS Then
  5.             Console.ForegroundColor = ConsoleColor.Red
  6.             Console.WriteLine("Call(..) Method returned error: " +
  7. xError.ToString() + " " & vbLf)
  8.             Console.ForegroundColor = cc
  9.  
  10.             w2cDrv.Device.HangUp(False)
  11.             MyHangUpCall = 0
  12.             MyCallConnected = 0
  13.             Console.WriteLine(sLogo)
  14.             GoTo renternumber
  15.         End If
  16.         ' wait key press ...
  17.         Console.WriteLine("Calling " + sNumber + ", Press any key to
  18. end, 'a' for another call." & vbLf)
  19. 'this is where it waits for user to hit key and this is where i would want to pause
  20.         cki = Console.ReadKey(False)
  21.  
  22.         If cki.KeyChar = "a"c Then
  23.             w2cDrv.Device.HangUp(False)
  24.             MyHangUpCall = 0
  25.             MyCallConnected = 0
  26.  
  27.             Console.Clear()
  28.             Console.WriteLine(sLogo)
  29.             GoTo renternumber
  30.         End If
  31. mainend:
  32.         iErr = w2cDrv.Device.Close(0)
  33.         'close the device
  34.         ' handle errors ...
  35.         iErr = w2cDrv.ShutdownDriver(0)
  36.         'must be last called
  37.         ' handle errors ...
Apr 9 '10 #1
0 988

Sign in to post your reply or Sign up for a free account.

Similar topics

13
2804
by: BK | last post by:
Can someone point me to a code sample that illustrates executing long running tasks (asynchronous) from a web application in ASP.NET? I assume that Web Services might come into play at some point,...
10
3025
by: MikeE | last post by:
Hi all, What's the best way to queue up and wait for number of threads to complete. This problem was trivial in VC++ 6 but I'm finding it rather hard to solve in VB.NET. My calculations run...
39
789
by: jabailo | last post by:
I am looping through a text file, and with each row, I launch a web service, asynchronously. Before I move on to the next step in the process, I want to make sure that all the web services have...
7
2670
by: Charles Law | last post by:
My first thought was to call WorkerThread.Suspend but the help cautions against this (for good reason) because the caller has no control over where the thread actually stops, and it might have...
6
7627
by: Hugh Janus | last post by:
Hi group, I am executing a shell command that calls a .BAT file. I have to wait for this batch file to finish so I use the wait = true parameter in the shell command. However, this means that...
0
2725
by: Gordon Cone | last post by:
I am currently debugging a deadlock in a multithread C# application. It makes lots of calls to legacy unmanaged code. The application runs on windows sever 2003 and uses the sever version of the...
2
5235
by: BLUE | last post by:
I would like to pause an application while the GUI display a Label saying "Logging in...". System.Timers System.Windows.Forms.Timer System.Threading.Timer System.Threading ==Thread.Sleep ...
0
2123
by: Grayzag | last post by:
Hi there, As part of my Software course, i have to create a game. Since I originally started out with python, I was used to it being really easy to create a main loop to control the game with a...
2
3507
by: Amit Dedhia | last post by:
Hi I am developing a scientific application which has moderate level image processing involved. In my application, there is a main application form which invokes another form. When this form...
0
7136
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.