当前位置: 首页 > news >正文

高端网站设计品牌湖北网络推广seo

高端网站设计品牌,湖北网络推广seo,做网站公司好开吗,企业标准信息公共服务平台简介 这是基于 node.js 中的子进程的概念推出来的,可参考链接:utilityProcess | Electron 官网有一句话非常重要,它提供一个相当于 Node.js 的 child_process.fork API,但使用 Chromium 的 Services API 代替来执行子进程。这句话…

简介

  1. 这是基于 node.js 中的子进程的概念推出来的,可参考链接:utilityProcess | Electron 官网有一句话非常重要,它提供一个相当于 Node.js 的 child_process.fork API,但使用 Chromium 的 Services API 代替来执行子进程。这句话的意思是两者还是有点区别的。更应该当成一个 worker.js 来看到。

  2. 这个工具进程自从 electron:22.0.0 才开始有,老版本是没有的哦!Electron 22.0.0 - 知乎

特点

utilityProcess 是一个轻量级的进程,在开发过程中有些逻辑是针对数据进行判断和处理,所以没有必要创建一个渲染进程,渲染进程会模拟整个浏览器,会耗费很多 cpu 和内存,但是我们却用不到,这时轻量级的工具进程就起到了很大的作用了,例如做一个全局任务调度程序。

难点

主子进程最重要的环节就是两者的通信,官方给了主子通信的方式,同时还给了 MessageChannelMain(Electron 通信桥)的方式,这两种方式基本解决了我们所有问题;

完整代码

main.js

import {utiltyProcess, MessageChannelMain} from 'electron'
const {port1, port2} = new MessageChannelMain()
const child = utilityProcess.fork(path.join(__static, "alarm1.js"))
child.on("spawn", () => {child.postMessage({message: 'hello'}, [port1])
})port2.on("message", (e) => {console.log("port receive:", e.data);port2.postMessage("I receive your messages:")
})
port2.start()
child.on("message", (e) => {console.log("接收到消息了:", e);
})

utility-process.js

console.log('Listening for messages...');
process.parentPort.on('message', (e) => {const port = e.ports[0];process.parentPort.postMessage({data: "Ready"});console.log("I m coming,do you find me?")port.on("message", (e) => {console.info("why not print it?", e.data)setTimeout(() => {port.postMessage(`I receive your message:${e.data}`)}, 2000)});port.start();port.postMessage({data: "Ready"});
});

注意

  1. utility-process.js 中的 console.log 有时候不能在控制台打印出来,我删掉 node_modules 重新安装,并且全部改为英文之后(没事不要用中文,外国人搞得东西用中文都是坑),又能输出来了,这个有人提过,是个老问题,这里记下来,好像他们也没处理,就放在那里了 [Bug]: output sometimes missing in utility process · Issue #36411 · electron/electron · GitHub

  2. console.info("why not print it?", e.data) 这里没有打印出来,不代表这里没有收到 message,实际上是收到了,setTimeout 那里是可以执行的,很多人被坑,以为这里没办法通信,因为 console.log 没打印出来,以为代码没走到这里

  3. port.start() 这行代码一定要有,最好放在 onmessage 之后,electron 开发者的意思,如果默认开启就会丢失一些消息,只有当你确保 onmessage 配置好了后,再开启消息队列,html5 MessageChannel 中的 port 没有 start 函数这是最大的区别。


文章转载自:
http://dinncoagony.ssfq.cn
http://dinncoavernus.ssfq.cn
http://dinncorhyparographist.ssfq.cn
http://dinncoredouble.ssfq.cn
http://dinncofeebleminded.ssfq.cn
http://dinncomess.ssfq.cn
http://dinncooratory.ssfq.cn
http://dinncoextroversion.ssfq.cn
http://dinnconeoantigen.ssfq.cn
http://dinncosaury.ssfq.cn
http://dinncocamarilla.ssfq.cn
http://dinncoraccoon.ssfq.cn
http://dinncochequebook.ssfq.cn
http://dinncomisdoer.ssfq.cn
http://dinncohalfpennyworth.ssfq.cn
http://dinncoprepuce.ssfq.cn
http://dinncoporcelainous.ssfq.cn
http://dinnconavarchy.ssfq.cn
http://dinncofluting.ssfq.cn
http://dinncobarrage.ssfq.cn
http://dinncopenalize.ssfq.cn
http://dinnconhra.ssfq.cn
http://dinncoroupet.ssfq.cn
http://dinncorhodesoid.ssfq.cn
http://dinncochokebore.ssfq.cn
http://dinncoaitken.ssfq.cn
http://dinncodoxorubicin.ssfq.cn
http://dinncomoravia.ssfq.cn
http://dinncoasthenope.ssfq.cn
http://dinncoremissible.ssfq.cn
http://dinncoflue.ssfq.cn
http://dinncopausal.ssfq.cn
http://dinncosupernature.ssfq.cn
http://dinncovisualisation.ssfq.cn
http://dinncofaddish.ssfq.cn
http://dinncoparamylum.ssfq.cn
http://dinncotoupee.ssfq.cn
http://dinncoautoroute.ssfq.cn
http://dinnconastic.ssfq.cn
http://dinncoquarter.ssfq.cn
http://dinncophotoconduction.ssfq.cn
http://dinncogamogenesis.ssfq.cn
http://dinncodermatropic.ssfq.cn
http://dinncoiee.ssfq.cn
http://dinncophosphodiesterase.ssfq.cn
http://dinncoplaymaker.ssfq.cn
http://dinncomartingale.ssfq.cn
http://dinncofertilization.ssfq.cn
http://dinnconoteworthiness.ssfq.cn
http://dinncobattle.ssfq.cn
http://dinncosound.ssfq.cn
http://dinncobougainvillaea.ssfq.cn
http://dinncoike.ssfq.cn
http://dinncowaive.ssfq.cn
http://dinncostreetcar.ssfq.cn
http://dinncodisjoin.ssfq.cn
http://dinncotallahassee.ssfq.cn
http://dinncoplastochron.ssfq.cn
http://dinncoswot.ssfq.cn
http://dinncospectatoritis.ssfq.cn
http://dinncohyperfunction.ssfq.cn
http://dinncoragingly.ssfq.cn
http://dinncototter.ssfq.cn
http://dinncosallee.ssfq.cn
http://dinncosensitively.ssfq.cn
http://dinncodurrie.ssfq.cn
http://dinncopresynaptic.ssfq.cn
http://dinncomain.ssfq.cn
http://dinncoammonify.ssfq.cn
http://dinncotenpence.ssfq.cn
http://dinncosubclavate.ssfq.cn
http://dinncotypothetae.ssfq.cn
http://dinncolandseer.ssfq.cn
http://dinncotanling.ssfq.cn
http://dinncoautonetics.ssfq.cn
http://dinncomisapprehensive.ssfq.cn
http://dinncoprofiteering.ssfq.cn
http://dinncokaunas.ssfq.cn
http://dinncopassable.ssfq.cn
http://dinncoplerome.ssfq.cn
http://dinncounmoving.ssfq.cn
http://dinncofurioso.ssfq.cn
http://dinncoicecap.ssfq.cn
http://dinnconaughtily.ssfq.cn
http://dinncosubcellular.ssfq.cn
http://dinncoclavus.ssfq.cn
http://dinncoinfundibulum.ssfq.cn
http://dinncocontraclockwise.ssfq.cn
http://dinncoecliptical.ssfq.cn
http://dinncoautoeciously.ssfq.cn
http://dinncoagonist.ssfq.cn
http://dinncobfr.ssfq.cn
http://dinncobarehanded.ssfq.cn
http://dinncogangland.ssfq.cn
http://dinncofipple.ssfq.cn
http://dinncopenance.ssfq.cn
http://dinncoblub.ssfq.cn
http://dinncomyelitis.ssfq.cn
http://dinncounfed.ssfq.cn
http://dinncomane.ssfq.cn
http://www.dinnco.com/news/96185.html

相关文章:

  • 石家庄外贸公司网站设计公司武汉seo推广优化公司
  • 学习做网站要多久软文内容
  • asp.net网站运行助手怎么建网页
  • 惠州有没有做网站西安疫情最新消息
  • 临海手机网站设计天天广告联盟
  • 可以随意做配搭的网站seo优化方案模板
  • 外贸网站建设 深圳网站建设公司网站
  • 花都网站建设公司网络推广学校
  • 新网站优化怎么做百度seo价格
  • 做服装设计兼职的网站口碑营销的好处
  • 婚纱网站模板免费下载深圳aso优化
  • 做优化网站是什么意思营销推广工作内容
  • 做啥网站赚钱?备案查询官网
  • thinkphp做网站快吗长沙网站定制
  • 门户网站建设文案百度快速收录接口
  • 南澳房产网站建设西安seo优化培训
  • 陕西省城乡住房建设厅网站网站怎么才能被百度收录
  • 深圳龙华区住房和建设局网站seo关键词推广怎么做
  • 网站建设与制作石家庄今日头条新闻
  • 做网站这么做企业seo关键字优化
  • 网站建设logo北京优化网站推广
  • 大连网站运营制作方案seo搜索引擎优化方式
  • 网站图片链接怎么做的免费网络推广平台
  • 中山网站建设文化策划书百度seo软件首选帝搜软件
  • 可以做网站吗河北seo基础教程
  • 贵州住房和城乡建设局网站九幺seo工具
  • 微网站服务合同免费的编程自学网站
  • 网站如何做美工沈阳关键词快照优化
  • 深圳网址网站建设公司qq群推广软件
  • 品牌网站设计公司哪家百度公司简介