You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
; In the C# bridge, this is defined as a public void. It uses _webView.Invoke to send the command to the UI thread and exits immediately. It does not wait for the JavaScript to execute, and it has no return type.
183
+
; Use case: Clicking buttons, scrolling, or triggering JS events where you don't care about the result.
184
+
; 1. ExecuteScriptOnPage (Async-Void Trap)
185
+
; This is defined as public async void. In COM Interop (which AutoIt uses), an async void method returns control to the caller (AutoIt) the moment it hits the first internal await. The script runs in the background, but the result is never passed back to the COM interface.
186
+
; Use case: Fast execution where background processing is acceptable, but again, no return value.
187
+
; 2. ExecuteScriptWithResult
188
+
; This is the only method designed to return data. It implements a Message Pump (using Application.DoEvents()) to keep the interface responsive while waiting up to 5 seconds for the result.
189
+
; Key Features of ExecuteScriptWithResult:
190
+
; Blocking: It waits for the script to finish (Sync-like behavior for AutoIt).
191
+
; JSON Cleaning: WebView2 returns results as JSON strings (e.g., "Hello"). This method automatically strips the extra quotes and unescapes the string for you.
192
+
; Error Handling: Returns ERROR: Script Timeout if the JS takes longer than 5 seconds.
177
193
; Related .......:
178
-
; Link ..........:
194
+
; Link ..........: https://github.com/ioa747/NetWebView2Lib/issues/45#issuecomment-3831184514
0 commit comments