-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
140 lines (139 loc) · 7.14 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<html>
<head>
<script>
const params = new URL(document.location).searchParams;
let version = params.get("version");
const electronVersion = params.get("electron-version");
version = version.charAt(0).toUpperCase() + version.substr(1);
const namespace = "QuickStart." + version + ".dll";
</script>
<meta charset="UTF-8" />
<title>electron-edge-js Quick Start</title>
<script src="./renderer.js" defer></script>
<link rel="stylesheet" href="default.css" />
</head>
<body>
<h3 id="test">
Quick start for electron-edge-js module using .NET
<script>
document.write(version);
</script>
and Electron
<script>
document.write(electronVersion);
</script>
</h3>
<table>
<tr>
<th style="background: #c4d4e5" colspan="2">
<strong>
Calling local methods from
<script>
document.write(namespace);
</script>
</strong>
</th>
</tr>
<tr>
<th class="method">Method</th>
<th>Result</th>
</tr>
<tr>
<td class="method">GetAppDomainDirectory</td>
<td><pre id="GetAppDomainDirectory"></pre></td>
</tr>
<tr>
<td class="method">GetCurrentTime</td>
<td><pre id="GetCurrentTime"></pre></td>
</tr>
<tr>
<td class="method">Handle .NET Exception</td>
<td><pre id="HandleException"></pre></td>
</tr>
<tr>
<td class="method">UseDynamicInput</td>
<td><pre id="UseDynamicInput"></pre></td>
</tr>
</table>
<br />
<table>
<tr>
<th style="background: #c4d4e5" colspan="2">
<strong>
Calling external library methods using
<script>
document.write(namespace);
</script>
wrapper
</strong>
</th>
</tr>
<tr>
<th class="method">Method</th>
<th>Result</th>
</tr>
<tr>
<td class="method">GetPersonInfo</td>
<td><pre id="GetPersonInfo"></pre></td>
</tr>
</table>
Using electron-edge-js, the C# code performs nearly exactly the same way that the
Node code performs. The C# code performs almost just as if it were Electron main
process code.<!-- All constraints in place on the Electron main process are also in
place in the C# code. -->
<br />
<br />
There are only two additional constraints applied to the C# code that are not
present for the Electron main process code:
<ol>
<li>The C# code must always accept one and only one 'dynamic' argument and return
a Task<object>. This means the C# code can never be written fully
synchronously. This does not have any serious impact on the code from what I
can tell. You just have to put async on the signature of every C# method called
from edge.</li>
<li>The Electron main process code cannot determine if a C# method should be
called with the synchronous Edge function call
<code>edgeFunc(args, true): any</code> or with the asynchronous Edge function
call <code>edgeFunc(args, (error, result) => void): void</code>. There must be
some programmatic way to determine which Edge function call to use. The easiest
way to deal with this issue is calling all Edge functions asynchronously! Or
you can use a keyword in the namespace, class, or method name like "Sync" and
detect that when calling the Edge function. Or you can list all synchronous C#
methods in an array and check if the method is in that array when calling the
Edge function.</li>
</ol>
Following are some example Edge functions and what they demonstrate:
<br />
<br />
<button id="ShortAsynchronousElectronMethod" type="button">Short Asynchronous Electron Method</button> Calling a short asynchronous Electron method (with no actual asynchronous operations) does not appear to hold up the renderer as it its execution time is very short.
<br />
<button id="ShortAsynchronousMethod" type="button">Short Asynchronous C# Method</button> Calling a short asynchronous C# method (with no actual asynchronous operations) is just like calling a short asynchronous Electron method. Its execution does not appear to hold up the renderer.
<br />
---
<br />
<button id="ShortSynchronousElectronMethod" type="button">Short Synchronous Electron Method</button> Calling a short synchronous Electron method does not appear to hold up the renderer as its execution time is very short.
<br />
<button id="ShortAsynchronousMethodSynced" type="button">Short Asynchronous C# Method Force Synced</button> Calling a short asynchronous C# method with the synchronous Edge function call is just like calling a short synchronous Electron method. Its execution does not appear to hold up the renderer.
<br />
<button id="ShortSynchronousMethod" type="button">Short Synchronous C# Method</button> Calling synchronous C# methods does not work as they do not return a Task<object>.
<br />
---
<br />
<button id="LongAsyncElectronMethod" type="button">Long Async Electron Method</button> Calling a long asynchronous Electron method that awaits asynchronous operations does not appear to hold up the renderer as it waits for the scheduler to run it and its actual execution time is very short.
<br />
<button id="LongAsyncMethod" type="button">Long Async C# Method</button> Calling a long asynchronous C# method that awaits asynchronous operations is just like calling a long asynchronous Electron method. It does not appear to hold up the renderer.
<br />
---
<br />
<button id="LongBlockingElectronMethod" type="button">Long Blocking Async Electron Method</button> Calling a long asynchronous Electron method that blocks the process does hold up the renderer as its actual execution time is very long. This is somewhat strange to me as I would expect that blocking the main process would not block the renderer process.
<br />
<button id="LongBlockingMethod" type="button">Long Blocking Async C# Method</button> Calling a long asynchronous C# method that blocks the process as in the reported <a href="https://github.com/agracio/electron-edge-js/issues/97" target="_blank" >issue #97</a> is just like calling a long blocking asynchronous Electron method. It does hold up the renderer.
<br />
---
<br />
<button id="LongAsyncMethodSynced" type="button">Long Async C# Method Force Synced</button> Calling a long asynchronous C# method that awaits asynchronous operations with the synchronous Edge function call does not work as Edge detects that its Task<object> has not completed in the synchronous execution time.
<br />
<button id="LongBlockingMethodSynced" type="button">Long Blocking C# Method Force Synced</button> Calling a long synchronous C# method that blocks the process with the synchronous Edge function call works as Edge detects that its Task<object> has completed in the synchronous execution time. As seen above in the blocking asynchronous call, it does hold up the renderer.
</body>
</html>