// 现在把 Main 函数搬到这里来。避免用户搞不清主进程和渲染进程的区别,在 Program.cs 里面写太多代码导致子进程内部出现问题。
// Now move the Main function here. To avoid users not knowing the difference between the main process and the rendering process, write too much code in Program.cs, which causes problems in the sub-process.
#if NETCOREAPP3_1_OR_GREATER
// To customize application configuration such as set high DPI settings or default font,
//Error address test specifies the address of the error page. If the page fails to load, WinFormium's built-in error page will be automatically displayed.
//Url = "http://static1.app.local/";
//注意,默认没有指定任何Url,新版WinFormium将会自动加载一个欢迎页面。
//If no URL is specified, WinFormium will automatically load a welcome page.
// Register front-end message handler. For example, by registering “bbb” here, you can send messages to this handler from the front-end using the formium.postMessage("bbb", "[any data type/string/number/array/object]") method.
// Register front-end request handler. The difference between a request handler and a message handler is that a request handler needs to return a result.
// 请求处理器提供了2中不同的接口返回数据,一种是同步接口,一种是异步接口。
// The request handler provides two different interfaces for returning data: synchronous and asynchronous.
// This is the synchronous interface. The front-end can send a request to this handler using formium.sendHostWindowRequest("rrr", "[any data type/string/number/array/object]"), and this request will block the front-end thread until the handler returns a result.
// This is the asynchronous interface. The front-end can send a request to this handler using formium.sendHostWindowRequestAsync("aaa", "[any data type/string/number/array/object]"), and this request will not block the front-end thread. The front-end thread will continue executing, and you can use the resolve([data: any]) or reject([reason: string]) methods of the promise parameter to specify whether this asynchronous operation is successfully executed.
// The front-end's formium.sendHostWindowRequestAsync() method will return a awaitable promise object. You can use the await keyword to wait for the execution result of this promise object. Alternatively, you can also use the traditional then/catch methods.
//Test post message from back-end to front-end, the front-end needs to use the formium.addMessageDispatcher("test", msg=>{}) method to receive the message.
Task.Run(async () =>
{
while (true)
{
await Task.Delay(5000);
PostJavaScriptMessage("test", DateTime.Now);
}
});
*/
}
// 使用对象映射的方式来为WinFormium提供可前后端交互的JavaScript对象。
// Use object mapping to provide JavaScript objects that can interact with the front and back ends for WinFormium.
// 现在把 Main 函数搬到这里来。避免用户搞不清主进程和渲染进程的区别,在 Program.cs 里面写太多代码导致子进程内部出现问题。
// Now move the Main function here. To avoid users not knowing the difference between the main process and the rendering process, write too much code in Program.cs, which causes problems in the sub-process.
#if NETCOREAPP3_1_OR_GREATER
// To customize application configuration such as set high DPI settings or default font,
//Error address test specifies the address of the error page. If the page fails to load, WinFormium's built-in error page will be automatically displayed.
//Url = "http://static1.app.local/";
//注意,默认没有指定任何Url,新版WinFormium将会自动加载一个欢迎页面。
//If no URL is specified, WinFormium will automatically load a welcome page.
// Register front-end message handler. For example, by registering “bbb” here, you can send messages to this handler from the front-end using the formium.postMessage("bbb", "[any data type/string/number/array/object]") method.
// Register front-end request handler. The difference between a request handler and a message handler is that a request handler needs to return a result.
// 请求处理器提供了2中不同的接口返回数据,一种是同步接口,一种是异步接口。
// The request handler provides two different interfaces for returning data: synchronous and asynchronous.
// This is the synchronous interface. The front-end can send a request to this handler using formium.sendHostWindowRequest("rrr", "[any data type/string/number/array/object]"), and this request will block the front-end thread until the handler returns a result.
// This is the asynchronous interface. The front-end can send a request to this handler using formium.sendHostWindowRequestAsync("aaa", "[any data type/string/number/array/object]"), and this request will not block the front-end thread. The front-end thread will continue executing, and you can use the resolve([data: any]) or reject([reason: string]) methods of the promise parameter to specify whether this asynchronous operation is successfully executed.
// The front-end's formium.sendHostWindowRequestAsync() method will return a awaitable promise object. You can use the await keyword to wait for the execution result of this promise object. Alternatively, you can also use the traditional then/catch methods.
//Test post message from back-end to front-end, the front-end needs to use the formium.addMessageDispatcher("test", msg=>{}) method to receive the message.
Task.Run(async () =>
{
while (true)
{
await Task.Delay(5000);
PostJavaScriptMessage("test", DateTime.Now);
}
});
*/
}
// 使用对象映射的方式来为WinFormium提供可前后端交互的JavaScript对象。
// Use object mapping to provide JavaScript objects that can interact with the front and back ends for WinFormium.