problem with C# lock and windows2000 callback

F

fc

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.

here's some more details ... first off, i'm logging when i
enter and exit handleEvent. if it were working correctly
the output should look like this (where button2 is the
cancel button):

<start>
msg = button2_Click
Entering handleEvent.
*** button2
*** stopping speaking
Exiting. Thread

msg = axTextToSpeech1_SpeakingDone
Entering handleEvent.
*** speaking done
Exiting handleEvent.
<end>

---
instead the output looks like this:

<start>
msg = button2_Click
Entering handleEvent.
*** button2

msg = axTextToSpeech1_SpeakingDone
Entering handleEvent.
*** speaking done
Exiting handleEvent.
*** stopping speaking
Exiting handleEvent.
<end>

so in other words, it's not that handleEvent exits, it
gets interrupted and then things get out of sync. i don't
know that much about threads, but it seems to me that even
if the thread created automatically for the TTS it
shouldn't be able to access something that's locked.

second, i've tried an analogous setup w/ a diff. active x
component, namely the microsoft multimedia player, and the
locking works just fine.

also, another thing i tried is that inside the callback
for the abort button click instead of just directly
calling handleEvent i tried manually creating a thread
that calls a method that calls handleEvent with the
message to abort. in this case i also don't get the locking
problem.

thanks in advance ...
 
F

fc

i'm pretty sure i've figured this out. i'm pretty sure the
problem is b/c for this older MS SAPI (4.0) stopspeaking()
(and hence speaking_done) is synchronous, while speak() is
not. the docs i downloaded from MS aren't explicit about
whether or not it's synchronous, but as far as i can tell
it is.
 

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