Skip to content

Commit

Permalink
dispose task result to fix hanging on Windows (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
pviotti authored Dec 7, 2019
1 parent 0697b16 commit 4b1c8d1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions SayIt/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ let getVoiceId (voice: VoiceType) =

let handleSynthesisResult (task: Task<SpeechSynthesisResult>) =
task.Wait()
match task.Result.Reason with
use result = task.Result
match result.Reason with
| ResultReason.Canceled ->
let cancellation = SpeechSynthesisCancellationDetails.FromResult task.Result
let cancellation = SpeechSynthesisCancellationDetails.FromResult result
if CancellationReason.Error = cancellation.Reason then
match cancellation.ErrorCode with
| CancellationErrorCode.ConnectionFailure ->
Expand All @@ -27,7 +28,8 @@ let handleSynthesisResult (task: Task<SpeechSynthesisResult>) =
| _ ->
printfn "Error: ErrorCode=%A\nErrorDetails=%A" cancellation.ErrorCode cancellation.ErrorDetails
1
| _ -> 0
| _ ->
0

let performSpeechSynthesis(config: Argu.ParseResults<Args>, speechConfig: SpeechConfig) =
if config.Contains Output then
Expand Down

0 comments on commit 4b1c8d1

Please sign in to comment.