【发布时间】:2014-08-23 14:00:58
【问题描述】:
我有以下代码用于在 Windows Phone 8 中使用文本到语音功能。我正在使用带有书签的 ssml。但是当在 Bookmark 事件调用函数中更改任何 UI 元素时,会引发 Unauthorized Exception。
private void Initialise_synthesizer()
{
this.synthesizer = new SpeechSynthesizer();
synthesizer.BookmarkReached += new TypedEventHandler<SpeechSynthesizer, SpeechBookmarkReachedEventArgs>
(BookmarkReached);
}
void BookmarkReached(object sender, SpeechBookmarkReachedEventArgs e)
{
Debugger.Log(1, "Info", e.Bookmark + " mark reached\n");
switch (e.Bookmark)
{
case "START":
cur = start;
break;
case "LINE_BREAK":
cur++;
break;
}
**error here** t1.Text = cur.ToString();
}
但运行时出现以下错误
A first chance exception of type 'System.UnauthorizedAccessException' occurred in System.Windows.ni.dll
An exception of type 'System.UnauthorizedAccessException' occurred in System.Windows.ni.dll and wasn't handled before a managed/native boundary
Invalid cross-thread access.
知道如何解决此错误,或任何解决方法。
【问题讨论】:
标签: windows-phone-8 text-to-speech