在Windows Phone 8中,我有以下一段使用文本轉語音功能的代碼。我正在使用帶有書籤的ssml。但是,當更改Bookmark事件中的任何UI元素(稱爲函數)時,會引發未授權的異常。System.UnauthorizedAccessException在Windows Phone 8中使用文本轉語音功能
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.
任何想法如何圍繞解決這個錯誤,或任何工作。
它 -
由於
synthesizer.SpeakSsmlAsync()
是一個異步函數,執行UI操作調度員已被使用,這樣的事情。 –