|
44 | 44 | return jsonData; |
45 | 45 | } |
46 | 46 |
|
47 | | - |
48 | 47 | async function InvokeDoSyncWork() { |
49 | 48 | LogMessage("Invoking DoSyncWork"); |
50 | 49 | await window.HybridWebView.InvokeDotNet('DoSyncWork'); |
|
69 | 68 | LogMessage("Invoked DoSyncWorkParamsReturn, return value: message=" + retValue.Message + ", value=" + retValue.Value); |
70 | 69 | } |
71 | 70 |
|
| 71 | + async function InvokeDoAsyncWork() { |
| 72 | + LogMessage("Invoking DoAsyncWork"); |
| 73 | + await window.HybridWebView.InvokeDotNet('DoAsyncWork'); |
| 74 | + LogMessage("Invoked DoAsyncWork"); |
| 75 | + } |
| 76 | + |
| 77 | + async function InvokeDoAsyncWorkParams() { |
| 78 | + LogMessage("Invoking DoAsyncWorkParams"); |
| 79 | + await window.HybridWebView.InvokeDotNet('DoAsyncWorkParams', [123, 'hello']); |
| 80 | + LogMessage("Invoked DoAsyncWorkParams"); |
| 81 | + } |
| 82 | + |
| 83 | + async function InvokeDoAsyncWorkReturn() { |
| 84 | + LogMessage("Invoking DoAsyncWorkReturn"); |
| 85 | + const retValue = await window.HybridWebView.InvokeDotNet('DoAsyncWorkReturn'); |
| 86 | + LogMessage("Invoked DoAsyncWorkReturn, return value: " + retValue); |
| 87 | + } |
| 88 | + |
| 89 | + async function InvokeDoAsyncWorkParamsReturn() { |
| 90 | + LogMessage("Invoking DoAsyncWorkParamsReturn"); |
| 91 | + const retValue = await window.HybridWebView.InvokeDotNet('DoAsyncWorkParamsReturn', [123, 'hello']); |
| 92 | + LogMessage("Invoked DoAsyncWorkParamsReturn, return value: message=" + retValue.Message + ", value=" + retValue.Value); |
| 93 | + } |
| 94 | + |
72 | 95 | </script> |
73 | 96 | </head> |
74 | 97 | <body> |
|
84 | 107 | <button onclick="InvokeDoSyncWorkReturn()">Call C# method (no params) and get simple return value</button> |
85 | 108 | <button onclick="InvokeDoSyncWorkParamsReturn()">Call C# method (params) and get complex return value</button> |
86 | 109 | </div> |
| 110 | + <div> |
| 111 | + <button onclick="InvokeDoAsyncWork()">Call C# async method (no params)</button> |
| 112 | + <button onclick="InvokeDoAsyncWorkParams()">Call C# async method (params)</button> |
| 113 | + <button onclick="InvokeDoAsyncWorkReturn()">Call C# async method (no params) and get simple return value</button> |
| 114 | + <button onclick="InvokeDoAsyncWorkParamsReturn()">Call C# async method (params) and get complex return value</button> |
| 115 | + </div> |
87 | 116 | <div> |
88 | 117 | Log: <textarea readonly id="messageLog" style="width: 80%; height: 10em;"></textarea> |
89 | 118 | </div> |
|
0 commit comments