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

Commit

Permalink
Create the TaskCompletionSource before registering for cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
borigas committed Oct 6, 2021
1 parent 8657192 commit 987109f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Xamarin.Essentials/TextToSpeech/TextToSpeech.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public async Task SpeakAsync(string text, int max, SpeechOptions options, Cancel
if (tcsUtterances?.Task != null)
await tcsUtterances.Task;

tcsUtterances = new TaskCompletionSource<bool>();

if (cancelToken != null)
{
cancelToken.Register(() =>
Expand Down Expand Up @@ -150,7 +152,6 @@ public async Task SpeakAsync(string text, int max, SpeechOptions options, Cancel
var parts = text.SplitSpeak(max);

numExpectedUtterances = parts.Count;
tcsUtterances = new TaskCompletionSource<bool>();

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

Expand Down

0 comments on commit 987109f

Please sign in to comment.