-
Notifications
You must be signed in to change notification settings - Fork 275
[AI Task] [Tizen.Network.WiFi] Add RunContinuationsAsynchronously to async TCS#7669
Open
JoonghyunCho wants to merge 1 commit into
Open
[AI Task] [Tizen.Network.WiFi] Add RunContinuationsAsynchronously to async TCS #7669JoonghyunCho wants to merge 1 commit into
JoonghyunCho wants to merge 1 commit into
Conversation
Every TaskCompletionSource in the WiFi async path is completed from a native callback thread. Without TaskCreationOptions.RunContinuationsAsynchronously, each SetResult/SetException runs the awaiter's continuation inline on that native callback thread. That risks deadlock when the continuation re-enters Interop.WiFi.* synchronously, and pins user code to the callback thread instead of the ThreadPool/SynchronizationContext. Adds the flag to all 13 TaskCompletionSource construction sites: WiFiManagerImpl.cs: Activate, ActivateWithWiFiPickerTested, Deactivate, Scan, ScanSpecificAP, BssidScan, HiddenAPConnect, StartMultiScan (8) WiFiAP.cs: Connect, ConnectWps, ConnectWpsWithoutSsid, Disconnect, ForgetAP (5) No public API change. Behavior change is limited to which thread runs the awaiter's continuation, which matches the documented async contract. Fixes #7620
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request updates multiple instantiations of TaskCompletionSource in WiFiAP.cs and WiFiManagerImpl.cs to use TaskCreationOptions.RunContinuationsAsynchronously. This ensures that task continuations are executed asynchronously, preventing potential deadlocks and improving thread pool utilization. There are no review comments, so we have no feedback to provide.
JoonghyunCho
commented
May 31, 2026
Member
Author
🤖 [AI Review]
Reviewed — no findings.
Scope checked:
- All 13
TaskCompletionSourceconstruction sites updated uniformly: 8 inWiFiManagerImpl.cs(ActivateAsync,ActivateWithWiFiPickerTestedAsync,DeactivateAsync,ScanAsync,ScanSpecificAPAsync,BssidScanAsync,HiddenAPConnectAsync,StartMultiScan) and 5 inWiFiAP.cs(ConnectAsync,ConnectWpsAsync,ConnectWpsWithoutSsidAsync,DisconnectAsync,ForgetAPAsync). - Constructor-only change: no public API signature changes, no behavior change for callers awaiting the returned
Task. - Intended semantic effect: continuations no longer run inline on the native callback thread, eliminating the inline-sync-wait deadlock class typical of native-callback-driven TCS code.
TaskCreationOptionsoverload is available on the target TFMs (net6.0/net8.0).- All affected TCS are
TaskCompletionSource<bool>orTaskCompletionSource<WiFiAP>— noTaskCompletionSource(non-generic) sites left unconverted.
No 🔴 critical issues, no 🟡 suggestions to flag.
Automated review — final merge decision rests with human reviewers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
TaskCreationOptions.RunContinuationsAsynchronouslyto all 13TaskCompletionSourceconstruction sites inTizen.Network.WiFiso that awaiter continuations no longer execute inline on the native callback thread.Changes
src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiManagerImpl.cs— 8 sites (ActivateAsync,ActivateWithWiFiPickerTestedAsync,DeactivateAsync,ScanAsync,ScanSpecificAPAsync,BssidScanAsync,HiddenAPConnectAsync,StartMultiScan).src/Tizen.Network.WiFi/Tizen.Network.WiFi/WiFiAP.cs— 5 sites (ConnectAsync,ConnectWpsAsync,ConnectWpsWithoutSsidAsync,DisconnectAsync,ForgetAPAsync).The only change per site is passing
TaskCreationOptions.RunContinuationsAsynchronouslyto theTaskCompletionSourceconstructor. No signature changes, no behavior change apart from where continuations run.Mode
Refactoring
Verification
dotnet buildonsrc/Tizen.Network.WiFi, 0 errors)Fixes #7620