I'm looking to pass additional parameters such as a string and bool to the SpeakCompleted event handler. Can you please help me know the proper way?
SpeechSynthesizer synth = new SpeechSynthesizer();
synth.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(synth_SpeakCompleted);
static void synth_SpeakCompleted(object sender, SpeakCompletedEventArgs e)
{
// Looking to get a string & bool here.
Console.WriteLine("\nThe SpeakAsync operation was cancelled!!");
}
Thank you!
As noted in the comments to your question, you cannot directly add information to an event defined by 3rd party code... so you'll need other ways to get the information to your event handler.
The usual way to do this is using class fields, i.e. define
at the top of your class, set them when the information become available, and then in the event
Once you do this it's often nicer to split the synthesizer handling off into a separate class, so these fields don't pollute the rest of your code.