problem with C# lock and windows2000 callback

S

spacedog

hi, i'm having a problem using C#'s lock and windows2000's text to
speech (vtext.dll) ... basically it looks like the callback from the
TTS is violating C#'s lock, which looks very very suspicious. here are
the particulars:

i've made a form that has two buttons, one to "start speaking" and one
to "cancel speaking", and i've registered the TTS's callback message
"speech_recognized" to call my method axTextToSpeech1_SpeakingDone.

each of the methods, button1_Click (i.e. start speaking),
button2_Click (cancel speaking), and axTextToSpeech1_SpeakingDone call
handleEvent(string msg), with msg being just the name of the callback
(e.g. button1_Click).

handleEvent has a lock covering the whole method, and within that a
case statement.

if msg == "button1_Click", just calls the axTextToSpeech1.Speak

if msg == "button2_Click", just calls axTextToSpeech1.StopSpeaking

if msg == "axTextToSpeech1_SpeakingDone", just prints a message.

i've put in log messages both to std out and to file, and it seems
pretty clear that if you press the start speaking and then cancel it
while it's still speaking, the "axTextToSpeech1_SpeakingDone" method
gets called and start going through handleEvent, *even though the
cancel msg is still going through the locked code* ...

has anyone noticed anything like this before?? is it just some weird
anomaly w/ this TTS? if so, is there some other TTS i can drop into my
GUI? i've tried to download a couple of others, but couldn't get them
to work.

thanks in advance.
 
N

Nicholas Paldino [.NET/C# MVP]

spacedog,

I am assuming that when the speaking begins, it is on another thread.
Because of this, I would think that a notification is passed to that other
thread. Because of this, the handleEvent method exits quickly, and while
there is something going on in another thread, you can still get
notifications.

For this reason, the lock is very quick, because it only is in the
handleEvent method for a short amount of time in any case. It seems like
you want to lock out the method on whether or not the operation is complete.

Of course, I don't know for sure thow TTS works. I'm assuming that it
works asynchronously.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top