Skip to content
This repository was archived by the owner on May 15, 2024. It is now read-only.

Commit 2627bf2

Browse files
authored
Merge pull request #1895 from borigas/TextToSpeechCancelHang
Fixes hang waiting for cancelled TextToSpeech
2 parents 20d627e + 8b83bf9 commit 2627bf2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Xamarin.Essentials/TextToSpeech/TextToSpeech.android.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ public async Task SpeakAsync(string text, int max, SpeechOptions options, Cancel
109109
if (tcsUtterances?.Task != null)
110110
await tcsUtterances.Task;
111111

112+
tcsUtterances = new TaskCompletionSource<bool>();
113+
112114
if (cancelToken != null)
113115
{
114116
cancelToken.Register(() =>
@@ -150,7 +152,6 @@ public async Task SpeakAsync(string text, int max, SpeechOptions options, Cancel
150152
var parts = text.SplitSpeak(max);
151153

152154
numExpectedUtterances = parts.Count;
153-
tcsUtterances = new TaskCompletionSource<bool>();
154155

155156
var guid = Guid.NewGuid().ToString();
156157

0 commit comments

Comments
 (0)