Does the electron framework allow multi-threading through web workers?(电子框架是否允许通过网络工作者进行多线程?)
问题描述
如果我制作了一个电子应用程序,我很难在谷歌上搜索我将如何进行多线程.会是网络工作者吗?
I am having a hard time googling how I would do multi-threading if I made an electron app. Would it be with web workers?
推荐答案
在渲染进程中你可以创建Web Workers,并且这些将在自己的线程中运行,但是 在这些 Web Workers 中将禁用节点集成 因为 Node 不是线程安全的.因此,如果您想在使用 Node 的单独线程中运行某些东西,那么您需要生成一个单独的进程,您可以使用 child_process.fork() 然后使用 send().
In the renderer process you can create Web Workers, and those will run in their own threads, however Node integration will be disabled in those Web Workers because Node isn't thread-safe. So if you want to run something in a separate thread that uses Node then you'll need to spawn a separate process, you can do so with child_process.fork() and then communicate with the new process using send().
这篇关于电子框架是否允许通过网络工作者进行多线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:电子框架是否允许通过网络工作者进行多线程?
基础教程推荐
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- Bokeh Div文本对齐 2022-01-01
