How to thread something in what will become a Windows Service....

I have something I'm writing as a windows form right now but it will
eventually be a Windows Service.  For a test, I have a submit button
and it's action is to call something that dials out on a usb phone
device.  While that device is dialing and waiting for DTMF input from
the call recipient, I need to pause the program and wait for the
callee to hang up.  The device I call has a bunch of handlers that
handle the keys being entered, etc.  I need to have these handlers
able to listen for events while the button click sub is waiting but be
able to continue when a hangup event occurs. I'm not asking for
someone to write code for me but just looking for some of the words I
can search for on the internet or some pointers...  Thanks very
much.   Chris

I've attached a bit of the code...

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

AddHandler CWay2callDriver.OnLineCurrentDrop, AddressOf OnLineDrop

Dim xError As CWay2callDriver.Errors = DirectCast(w2cDrv.Device.[Call]
("w" & strNumber, True, True), CWay2callDriver.Errors) 'So this is
where it calls out....

'I need to sort of pause here and not actually end the sub.  I tried
adding a do/while but it is in such a tight loop that the events never
fire when things happen on the dialer.

End Sub

Private Sub OnLineDrop(ByVal deviceID As UShort)
        MyHangUpCall = 0
        w2cDrv.Device.HangUp(False)
        w2cDrv.Device.Close(0)
        'close the device
        ' handle errors ...
        w2cDrv.ShutdownDriver(0)
        boolCallFinished = True
End Sub
0
dufus
11/25/2009 7:53:43 PM
dotnet.languages.vb 830 articles. 0 followers. Follow

6 Replies
1368 Views

Similar Articles

[PageSpeed] 56

In article
<7099a461-bf95-44da-b5d0-b2374da3f5c3@z35g2000prh.googlegroups.com>,
<dufus@connectedvision.com> wrote:

> I have something I'm writing as a windows form right now but it will
> eventually be a Windows Service.  For a test, I have a submit button
> and it's action is to call something that dials out on a usb phone
> device.  While that device is dialing and waiting for DTMF input from
> the call recipient, I need to pause the program and wait for the
> callee to hang up.  The device I call has a bunch of handlers that
> handle the keys being entered, etc.  I need to have these handlers
> able to listen for events while the button click sub is waiting but be
> able to continue when a hangup event occurs. I'm not asking for
> someone to write code for me but just looking for some of the words I
> can search for on the internet or some pointers...  Thanks very
> much.   Chris
> 
> I've attached a bit of the code...
> 
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> 
> AddHandler CWay2callDriver.OnLineCurrentDrop, AddressOf OnLineDrop
> 
> Dim xError As CWay2callDriver.Errors = DirectCast(w2cDrv.Device.[Call]
> ("w" & strNumber, True, True), CWay2callDriver.Errors) 'So this is
> where it calls out....
> 
> 'I need to sort of pause here and not actually end the sub.  I tried
> adding a do/while but it is in such a tight loop that the events never
> fire when things happen on the dialer.

You can't just pause, what you need to do is start a thread that does
your call and then returns whatever result it returns when finished (if
using BackgroundWorker that would be the whatever function you have to
handle the RunWorkerCompleted event).

-- 
J.B. Moreno
0
J
11/25/2009 9:52:05 PM
On Nov 25, 1:52=A0pm, "J.B. Moreno" <pl...@newsreaders.com> wrote:
> In article
> <7099a461-bf95-44da-b5d0-b2374da3f...@z35g2000prh.googlegroups.com>,
>
>
>
>
>
> <du...@connectedvision.com> wrote:
> > I have something I'm writing as a windows form right now but it will
> > eventually be a Windows Service. =A0For a test, I have a submit button
> > and it's action is to call something that dials out on a usb phone
> > device. =A0While that device is dialing and waiting for DTMF input from
> > the call recipient, I need to pause the program and wait for the
> > callee to hang up. =A0The device I call has a bunch of handlers that
> > handle the keys being entered, etc. =A0I need to have these handlers
> > able to listen for events while the button click sub is waiting but be
> > able to continue when a hangup event occurs. I'm not asking for
> > someone to write code for me but just looking for some of the words I
> > can search for on the internet or some pointers... =A0Thanks very
> > much. =A0 Chris
>
> > I've attached a bit of the code...
>
> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
>
> > AddHandler CWay2callDriver.OnLineCurrentDrop, AddressOf OnLineDrop
>
> > Dim xError As CWay2callDriver.Errors =3D DirectCast(w2cDrv.Device.[Call=
]
> > ("w" & strNumber, True, True), CWay2callDriver.Errors) 'So this is
> > where it calls out....
>
> > 'I need to sort of pause here and not actually end the sub. =A0I tried
> > adding a do/while but it is in such a tight loop that the events never
> > fire when things happen on the dialer.
>
> You can't just pause, what you need to do is start a thread that does
> your call and then returns whatever result it returns when finished (if
> using BackgroundWorker that would be the whatever function you have to
> handle the RunWorkerCompleted event).
>
> --
> J.B. Moreno- Hide quoted text -
>
> - Show quoted text -

Thanks for the pointer.  The backgroundworker class is exactly the
hint I was looking for....
-1
Stupid488
11/25/2009 10:02:15 PM
Actually, I still have a problem.  I created a background worker
process and moved the line that calls the dialer to the DoWork
event...  The problem is that the RunWorkerCompleted event happens
right after it runs the dialer...

The dialer is run like this: Dim xError As CWay2callDriver.Errors =
DirectCast(w2cDrv.Device.[Call] ("w" & strNumber, True, True),
CWay2callDriver.Errors)

I still need to figure out how to not close the worker process before
the dialer's Onlinedrop event occurs...

hmmm



0
Stupid488
11/26/2009 12:04:59 AM
Stupid488 <dufus@connectedvision.com> wrote:

> Actually, I still have a problem.  I created a background worker
> process and moved the line that calls the dialer to the DoWork
> event...  The problem is that the RunWorkerCompleted event happens
> right after it runs the dialer...
> 
> The dialer is run like this: Dim xError As CWay2callDriver.Errors =
> DirectCast(w2cDrv.Device.[Call] ("w" & strNumber, True, True),
> CWay2callDriver.Errors)
> 
> I still need to figure out how to not close the worker process before
> the dialer's Onlinedrop event occurs...

In the worker thread you have a loop that checks a variable/property
that you set in the onlinedrop event.

You worker thread will probably call System.Threading.Thread.Sleep.

-- 
J.B. Moreno
0
J
11/26/2009 12:21:32 AM
J.B. Moreno <planB@newsreaders.com> wrote:

> Stupid488 <dufus@connectedvision.com> wrote:
> 
> > Actually, I still have a problem.  I created a background worker
> > process and moved the line that calls the dialer to the DoWork
> > event...  The problem is that the RunWorkerCompleted event happens
> > right after it runs the dialer...
> > 
> > The dialer is run like this: Dim xError As CWay2callDriver.Errors =
> > DirectCast(w2cDrv.Device.[Call] ("w" & strNumber, True, True),
> > CWay2callDriver.Errors)
> > 
> > I still need to figure out how to not close the worker process before
> > the dialer's Onlinedrop event occurs...
> 
> In the worker thread you have a loop that checks a variable/property
> that you set in the onlinedrop event.
> 
> You worker thread will probably call System.Threading.Thread.Sleep.

On re-reading this, I"m not sure that you shouldn't have called Sleep
from the beginning -- I'm not clear on why you want to "pause" your
application.  If you have an event that gets fired, and want to do
further processing after that event is fired, the thing to do is to
call for the processing inside the event handler.

-- 
J.B. Moreno
0
J
11/26/2009 12:30:42 AM
On Nov 25, 4:30=A0pm, "J.B. Moreno" <pl...@newsreaders.com> wrote:
> J.B. Moreno <pl...@newsreaders.com> wrote:
> > Stupid488 <du...@connectedvision.com> wrote:
>
> > > Actually, I still have a problem. =A0I created a background worker
> > > process and moved the line that calls the dialer to the DoWork
> > > event... =A0The problem is that the RunWorkerCompleted event happens
> > > right after it runs the dialer...
>
> > > The dialer is run like this: Dim xError As CWay2callDriver.Errors =3D
> > > DirectCast(w2cDrv.Device.[Call] ("w" & strNumber, True, True),
> > > CWay2callDriver.Errors)
>
> > > I still need to figure out how to not close the worker process before
> > > the dialer's Onlinedrop event occurs...
>
> > In the worker thread you have a loop that checks a variable/property
> > that you set in the onlinedrop event.
>
> > You worker thread will probably call System.Threading.Thread.Sleep.
>
> On re-reading this, I"m not sure that you shouldn't have called Sleep
> from the beginning -- I'm not clear on why you want to "pause" your
> application. =A0If you have an event that gets fired, and want to do
> further processing after that event is fired, the thing to do is to
> call for the processing inside the event handler.
>
> --
> J.B. Moreno- Hide quoted text -
>
> - Show quoted text -

Good point.  I will go this route....
0
Stupid488
11/26/2009 12:41:28 AM
Reply:

Similar Artilces:

Exchange 2003 services list
Hi All, i want to know the services list for exchange 2003 and what they are doing, any web link or reference willbe helpful thanks in advance regards shajahan ...

Sales and Service Module not in the Navigation Bar.
Hi There, I've just installed MS CRM 1.2 using the demo key but i've noticed that Sales and Service modules are not being shown in the Navigation Bar. Only Home, Workplace and Reports are shown. Is this right? Thanks... It's the same even after re-installation. >-----Original Message----- >Hi There, > >I've just installed MS CRM 1.2 using the demo key but i've >noticed that Sales and Service modules are not being shown >in the Navigation Bar. Only Home, Workplace and Reports >are shown. Is this right? Thanks... >. > You need to i...

How to subclass an MFC window?
Is there any easy way of overriding the responses to some messages to a CWnd-derived object buried deep within MFC? One reason for the question is: In the old days CMainFrame was derived from CMDIFrameWnd and this had a member HWND m_hWndMDIClient; To draw the background of this window I used to do a SubclassWindow( ) on it, and with my own CWnd-derived object, respond to WM_ERASEBKGND messages. Nowadays CMainFrame is derived from CMDIFrameWndEx and this has a member CMDIClientAreaWnd m_wndClientArea; and (I think) because a CWnd object already exists for the M...

genre will not transfer correctly to mp3 player
I have wmp 11 and a 8GB sansa fuze mp3. Once I change the genre in wmp to let's say from soul/r&b to r&b, it will not change the genre on my sansa. I've tried and tried. Contacted San Disk for help and they said it was a media player issue. The genre will stay correctly in wmp but won't transfer correctly. Someone help! On Wed, 9 Dec 2009 11:52:01 -0800, Mitziepoo <Mitziepoo@discussions.microsoft.com> wrote: >I have wmp 11 and a 8GB sansa fuze mp3. >Once I change the genre in wmp to let's say from soul/r&b to r&b, it will >not c...

Hotmail will not receive/display messages sent from GMX or Yahoo
Messages sent from a GMX or Yahoo account using Windows Live Mail will not be received/displayed in Hotmail's inbox. However, if they are sent using Outlook Express, they are successfully received and displayed. Also, a message sent from G-Mail using Windows Live Mail (or Outlook Express) will work fine. Very unusual! When you say "Hotmail inbox" do you mean the one on the web or the one in your Windows Live Mail? Are the missing messages not visible in either location? Hotmail has very stringent (some would say 'draconian') spam filtering. It is not ...

Tab windows in SDI
I wish to create a tabbed window using CTabCtrl in an SDI application, where each of the tabbed windows is actually a class derived from CView class. Is there a way to do this? If not what would be a better way to do this? Any help will be really appreciated. Thanks Riya wrote: > I wish to create a tabbed window using CTabCtrl in an SDI application, > where each of the tabbed windows is actually a class derived from CView > class. > > Is there a way to do this? If not what would be a better way to do > this? Any help will be really appreciated. > > Thanks > I...

something about clipping in OnCustomdraw
hi folks;-) the following snipped comes from a customdraw-fn in a slider. As you can see, i draw my own thumb and want to set some text in the control: ____________________________________________________________ class SHTC_API CQSlider : public CSliderCtrl { public: CQSlider(); virtual ~CQSlider(); // ... other stuff ... // // set sliders text, may contain '%d' (or %x...) for value void QTitleSet(LPCTSTR szTitle); protected: //{{AFX_MSG(CQSlider) afx_msg void OnCustomdraw(NMHDR* pNMHDR, LRESULT* pResult); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: void _DrawThumb(NM...

IIS SMTP service as anSMTP Gateway to Exchange 5.5
I could use some input on what I am proposing below. Setup: Win2K wiht IIS 5.o SMTP service setup relaying to a NT 4.0 Exchange 5.5 box. (this is all working great) I have this setup to allow for Spam and Virus filtering amoung other reasons. Side note: because of things out of my control both oxes are avaible to the internet on some ports POP SMTP RPC etc.. I can't change this. Here's my problem: With this MyDoom virus I have noticed a problem with my present setup. Because I have POP3 users as well. They acccess the back exchange box. We have an A record for it. an...

Files will not open.
I loaded Pub 2003 but cannot open previous Pub 98 files. Noton Virus is not the problem as the prevoius Pub 98 files as Norton was not installed. Greetings, I wanted to provide a bit more information on my problem. I have 2 computers, one with Publisher 98 and one with Publisher 2003. I have a bunch of files made in Publisher 98 that won't open in Publisher 2003. When I try and click on a publisher file or open the file from within Publisher 2003, I get the error "Publisher cannot open the file". The files are not corrupted during the copy process, because if I copy them ba...

sending message in MFC multi-threading
I use class CSMTPConnection and CMimeMessage to send email in a multithreading project. when I only spawn one dialog window and send email, there is no problem at all, but whenever I spawn one more dialog window(concurrently), an exception occured. I traced it a little bit. The exception is about a pointer to interface IMultiLanguage while CMimeMessage instance initializing. Codes is as following class CMyDialog :public CDialog { CMyLog * m_log; void fcn(); ...... }; class CMyLog { .... void SendEmail( ....); .... }; void CMyLog::SendEmail(...) { CSMTPConnection EmailConn...

My Money Side will not stop
I read the FAQ for Money 2002 and it stated A) Click Help in MoneySide, then Settings. Under "Open MoneySide" select "Never" and then "Done." I select "Never" but there is no "Done" I can find and My Money leaves for this time only to return again. Is there any way to kill money from running in the background. It is not running in MSCONFIG on my XP sp2 system that I can find. Thanks Don I wish I had a way to test this here to tell you how to do it and validate the FAQ. Hopefully somebody who can still test on M02 will join the thread....

Console App w/ MFC (hiding console window)
I've created a console app and added MFC support. The idea is that my app can run either with a dialog user interface or a console. It all works fine except that I cannot figure out how to hide the console window when running in the dialog ui mode. Anyone know how I might do this? -Brett- Brett , > I've created a console app and added MFC support. The idea is that my app > can run either with a dialog user interface or a console. It all works fine > except that I cannot figure out how to hide the console window when running > in the dialog ui mode. You can set yo...

CDialog::Create() is blocked in GUI thread. Why?
Hi all, I am trying to use another GUI thread to show a dialog, but I found the CDialog::Create() will be blocked in the GUI thread. I start the GUI thread from a function in my main thread by using a calss that is derived from CWinThread. In CWinThread::InitInstance(), I new a dialog object and call its Create(). I found the Create() will be blocked until the function in my main thread is leaved. Have you encountered such situation before? Any suggestion is welcome. Thanks in advance. Justi Lin Justin wrote: > > Hi all, > > I am trying to use anot...

Improve Service Calendar scheduling by using nearest location
Hello, I have different sites providing the same service, I want that from service calendar, my users could schedule a service: 1) from the nearest site 2) if no resources available on this site, use any other site with available resources. Is CRM able to do this ? How to enter rules on the service to have this kind of selection ? Thanks for help. CS ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button...

Outlook 2007 will not display email addresses!
I can't imagine I'm the only one with this problem, yet I'm unable to find any information about this problem in any newsgroup, web forum, web page, etc... I just upgraded from Outlook Express to Outlook 2007. In an email message in Outlook 2007, if I double click on the name of the sender (or the receipient) nothing happens!!!! In Outlook Express, I would get a nice little window showing me their email address. How else can I find out the email address of a person? All I can see is their first/last name. Outlook is not an "upgrade" to Outlook Express. These two progr...

MSCRMDeletion Service | Deletion service failed to clean up some t
I was researching an error which has popped up on our CRM server (MSCRMDeletionService | Deletions service failed to clean up some tables) and came accross Microsoft KB921391 (http://support.microsoft.com/kb/921391). I ran through the solution and actually found that the error was in the ActivityPointer and therefore I wasn’t able to successfully run the accompanying SQL script as the subsequent step. Has anyone run across this issue before? ------=_NextPart_0001_2695F0DE Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi and thanks for the post. According to the kb article...

OUTLOOK 2003 in W7, New CONTACTS will not 'File As' properly
I upgraded to W7 and reinstalled Outlook 2003 a few weeks ago. Now I notice that new Contacts that I add do not file Lastname, First as instructed in 'View or Change Directories." Pre-existing Contacts are still ok. Any ideas about how to fix the problem, preferrably not "Get Outlook 2007?" Thanks "mcarpeneto" <mcarpeneto@discussions.microsoft.com> wrote in message news:BD3C49EB-F629-4840-AFD9-5CCE440DE0A4@microsoft.com... >I upgraded to W7 and reinstalled Outlook 2003 a few weeks ago. Now I notice > that new Contacts that I add do not...

Adding field in Scrolling window
Hello: I was wondering how can I add a field in scrolling window if it is not mapped in DB? Thanks candidcarper Use a local field, and assign a value to it in the Fill script on the scrolling window. "ammad_u@yahoo.com" wrote: > Hello: > > I was wondering how can I add a field in scrolling window if it is not > mapped in DB? > > Thanks > > candidcarper > > ...

windows update 03-11-10
do i need to keep all those updates on my PC ie... the updates that have been installed over a year ago? "timbo" <timbo@discussions.microsoft.com> wrote in message news:9BA5D186-44CD-4E17-B6E0-13385C151E1C@microsoft.com... > do i need to keep all those updates on my PC ie... the updates that have > been installed over a year ago? Why does this cause you concern ? -- "Don't pick a fight with an old man. If he is too old to fight, he'll just kill you." timbo wrote: > do i need to keep all those updates on my PC ie... the up...

Works2000 and Windows 98
Is Works 2000 compatible with Windows 98??? ...

how to copy conmanclient.exe and related files to the windows folder of device
I need to debug a winCE application over the ethernet using Visual Studio. I have connected to the device over the ethernet and now need to run conmanclient2.exe and cmaccept.exe before I can start debugging. However, I don't know how to copy these files over the ethernet. Please guide me. Thankyou! -- Message posted via http://www.pocketpcjunkies.com Remote File Viewer (Visual Studio Remote Tools from your start menu) -- Luca Calligaris (MVP-Windows Embedded) lucaDOTcalligarisATeurotechDOTcom www.eurotech.com "amephraim via PocketPCJunkies.com" <u583...

I want to make a VBScript to control Windows Media Player
Hi all, I'm able to control WMP through the shell but I think is not the cleanest solution. Can anybody help me on how to make the VBScript to use the WMP Activex or COM automation? I've found some reference about Player object and WMPLib but so far I've been getting compile or run time errors. the actions I want to do are: 1. Open the file I want to play 2. Start play 3. wait 10 seconds. 4. Pause/Stop play 5. wait 10 seconds. 6. return to step no. 2. I would appreciate your help very much. Regards. -- God grants us all at the cost of effort. Il giorno Wed,...

Logon Window never remembers my password
Hi, Despite setting up all the server settings correctly, the username and password screen pops up every time I want to send/receive mail. It's driving me crazy! How do I fix it? Thanks! :) Sharon Check here to see if any of the advice helps: http://www.howto-outlook.com/faq/passwordnotremembered.htm -- Kathleen Orland Outlook Tips: http://www.outlook-tips.net/ http://www.howto-outlook.com/ Outlook & Exchange Solutions Center: http://www.slipstick.com "Sharon Leonard" wrote: > Hi, > > Despite setting up all the server settings correctly, the userna...

Publisher will not print multiple copies, other apps do? Help!
I have tried everything I know how to do. Publisher will not print multiple copies, but other applications will. What version Publisher? Doe the print fail in all Publisher projects? Have you looked into an upgraded driver? Will Publisher print multiple copies if you change the number in the printer folder? -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "sidewinder" <sidewinder@discussions.microsoft.com> wrote in message news:0FBA3DCE-AE53-432E-8A7E-D6B3D6B1736A@microsoft.com... >I have tried everything I know h...

Cannot turn off select multiple items in Windows
We have Windows XP workstations running on a Windows Server 2003 domain. Sometimes, when a user clicks on a file in a folder, then clicks on another file in that same folder, all items in between the two get selected. The Shift key is not being pressed though. How do I turn this off? Up till now, all I can figure out is to logoff and login again. Anthony Fontana wrote: > We have Windows XP workstations running on a Windows Server 2003 > domain. Sometimes, when a user clicks on a file in a folder, then > clicks on another file in that same folder, all items in b...