4
내 음성 합성을 응용 프로그램에 추가합니다. 그것은 작동하지만 문제는 내가 연설을 취소 할 수 없다는 것입니다 ... 예를 들어, 다른 페이지로 이동하면 연설은 계속됩니다 ... 그래서, 현재 연설을 취소하기 위해 CancelAll() 메서드를 호출하지만 예외가 발생했습니다 왜 그런지 모르겠다. 무슨 문제인지 아십니까?Windows phone에서 음성 합성 취소 8
예외
A first chance exception of type 'System.Threading.Tasks.TaskCanceledException' occurred in mscorlib.ni.dll
An exception of type 'System.Threading.Tasks.TaskCanceledException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'System.Threading.Tasks.TaskCanceledException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
The program '[2576] TaskHost.exe' has exited with code -1 (0xffffffff).
내 코드 : 당신이 IAsyncAction
대신 await
을 사용 SpeakTextAsync
에서 반환 사용할 수있는 비동기 작업을 취소 할 때문에
private SpeechSynthesizer synth = new SpeechSynthesizer();
protected override void OnBackKeyPress(CancelEventArgs e)
{
//I tried to cancel also here but it's the same exception...
}
//method called when I press a button Cancel
private void ButtonCancelSpeech(object sender, EventArgs eventArgs)
{
try
{
synth.CancelAll();
}
catch (TaskCanceledException)
{
//I arrive in this exception
}
}
private async void BtnSpeech_Click(object sender, EventArgs e)
{
IEnumerable<VoiceInformation> voices = from voice in InstalledVoices.All
where voice.Language.Substring(0, 2).Equals(LanguageApp.GetLangage2Characters())
select voice;
if (voices.ElementAt(0) != null)
{
// Set the voice as identified by the query.
synth.SetVoice(voices.ElementAt(0));
await synth.SpeakTextAsync(_place.Description);
}
}
당신
완벽합니다. 감사합니다 – Volkan
당신은 환영합니다 :) – keyboardP
감사, 친구. –