-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added WebView2 wrapper and threadsafe postWebMessageAsJson (#1941)
- Loading branch information
1 parent
4202cf6
commit fc39181
Showing
5 changed files
with
31 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.Web.WebView2.WinForms; | ||
using System; | ||
|
||
namespace MobiFlight | ||
{ | ||
public class ThreadSafeWebView2 : WebView2 | ||
{ | ||
public void PostWebMessageAsJsonThreadSafe(string jsonMessage) | ||
{ | ||
if (this.InvokeRequired) | ||
{ | ||
this.Invoke(new Action(() => CoreWebView2.PostWebMessageAsJson(jsonMessage))); | ||
} | ||
else | ||
{ | ||
CoreWebView2.PostWebMessageAsJson(jsonMessage); | ||
} | ||
} | ||
} | ||
} |
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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