Re: Can't enable a Timer in a Speech Recognized handler

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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


.



Relevant Pages

  • Re: Cant enable a Timer in a Speech Recognized handler
    ... The Timer runs fine unless I try to use it in the event handler. ... any running Timer is not effected by the recognition event handler firing, ...
    (microsoft.public.dotnet.languages.vc)
  • Re: System.timers.timer in windows service??
    ... I move the code into the same function in the timer elapsed handler instead ... but no email message is sent and there is not error ...
    (microsoft.public.dotnet.framework)
  • Re: Timer Problem with Service
    ... call Stop on the 'timer' instance in your Elapsed ... | Do you happen to call Stop on the server instance in your Elapsed event ... I'll look into the Exception. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Cant enable a Timer in a Speech Recognized handler
    ... The Timer runs fine unless I try to use it in the event handler. ... any running Timer is not effected by the recognition event handler firing, ... and enables the timer. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Timer control
    ... not just timer events, will be missed. ... This is more accurate but should still not use a handler that takes ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Is the second tick event ignored? ...
    (microsoft.public.dotnet.framework.windowsforms.controls)