Re: Can't enable a Timer in a Speech Recognized handler
- From: "Peter Oliphant" <poliphant@xxxxxxxxxxxxxxxx>
- Date: Tue, 9 Oct 2007 10:08:57 -0700
I wish this newsgroup had an ability to at least attach a text file with
code. My code to demonstrate this situation is too long, and this newsgroup
tends to reformat the text in a bad way if the line is too long.
But, I'll try to explain it a bit more. Assume in the following that 'timer'
is set up with an interval and event handler:
System::Windows::Forms::Timer^ timer = gcnew Timer() ;
void Handler( Object^, SpeechRecognizedEventArgs^ e )
{
timer->Enable ; // problem!
}
That is, if I try to launch a timer inside the 'recognized speech' handler
it doesn't enable the timer. I believe it also locks out the timer from then
on (timer no longer responds to any commands). If this code is placed
outside of the handler, it launches the timer just fine.
FYI, using MS VS VC++ 2008 Express (Beta 2) with .NET Framework 3.5 on a
Vista machine. (SAPI 5.3 ala Vista). Managed (/cli) code generation.
I have a workaround, but it's not wonderful. I create an external 'master'
timer that polls whether other timers should be turned on via their
individual flags, and then set the flag of the timer to be launched in the
above handler instead. The disadvantage of course is that this adds an
unpredictable additonal lag (since it can make the request by setting the
timer flag at any point in the master timer's interval), although it is
short by human terms.
I tried moving this to the Recognition Completed handler of the speech
recognizer thinking perhaps it was the extensive recognition processing that
caused the problem. But that handler won't launch a timer either.
Hope that helps in the info department. This could be a problem or a
feature. If a problem, it could be part of SAPI or VC++.It could be a bug in
my code, but I've seen this happen two different ways (or NOT happeneing, if
you will), so this is not likely. I'm wondering if it is just disallowed in
general to launch a System Timer from an (any?) event handler. Can a Timer
handler launch another Timer, for instance?
Don't hesitate to ask if you want some specific questions asked...
Thanks!
[==Peter==]
"David Lowndes" <DavidL@xxxxxxxxxxxxxxx> wrote in message
news:l9img39rb7fdqkmvbqk4eaim32s1pv7j3a@xxxxxxxxxx
Note that although this involves SAPI, it is more a question about Timers
and event handlers.
I wrote a Speech Recognize handler (SAPI), and put some code in it to
enable
a Timer. It would not do it. If I bring this same code outside this event
handler, it works just fine.
And the code you've used it what?
You need to tell us a bit more!
Dave
.
- Follow-Ups:
- Re: Can't enable a Timer in a Speech Recognized handler
- From: William DePalo [MVP VC++]
- Re: Can't enable a Timer in a Speech Recognized handler
- From: David Lowndes
- Re: Can't enable a Timer in a Speech Recognized handler
- References:
- Can't enable a Timer in a Speech Recognized handler
- From: Peter Oliphant
- Re: Can't enable a Timer in a Speech Recognized handler
- From: David Lowndes
- Can't enable a Timer in a Speech Recognized handler
- Prev by Date: Re: Generic implementation of a smart pointer
- Next by Date: Re: Can't enable a Timer in a Speech Recognized handler
- Previous by thread: Re: Can't enable a Timer in a Speech Recognized handler
- Next by thread: Re: Can't enable a Timer in a Speech Recognized handler
- Index(es):
Relevant Pages
|