-
-
Notifications
You must be signed in to change notification settings - Fork 173
SafeFireAndForget is not safe #65
Copy link
Copy link
Closed
Labels
help wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested
Description
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested
https://github.com/brminnick/AsyncAwaitBestPractices/blame/main/README.md#L140
This line says that:
That couldn't be true, because implementation doesn't switch threads at all
https://github.com/brminnick/AsyncAwaitBestPractices/blob/d7ae1903f0a77913263a9bd81838faba70ef91a2/Src/AsyncAwaitBestPractices/SafeFireAndForgetExtensions.shared.cs#L77-L90
Everything prior first await will be executed on caller thread because that's how C# asyncs work (e.g. F# asyncs are different)
Code below will block caller thread for 5 sec before printing, which demonstrate that SafeFireAndForget isn't actually safe.