问题描述
[Powershell]::create()
-方法创建一个新的PowerShell-"实例".
the [Powershell]::create()
- method creates a new PowerShell-"Instance" either in the "current or a new runspace".
有人可以解释一下过程,实例,运行空间和(也许是线程)这两个术语之间的关系其他在这方面.用外行的话说吧?
Can someone explain how the terms process, instance, runspace and (maybe thread) relate to each other in this regard.In laymen's terms if possible?
推荐答案
您可以将[Powershell] :: Create()视为单独线程上的新powershell会话.该会话将创建一些默认的运行空间,但是您可以将其更改为另一个运行空间.与Start-Process(单独的进程)和Start-Job(子进程)不同,[Powershell] :: Create()与您的主脚本在同一进程上运行,并与其共享内存空间.这意味着您可以在主会话和子会话之间交换实际的.net对象.如果会话在单独的进程上运行,则只能与文本/序列化数据交换.
You can think of [Powershell]::Create() as a new powershell session on the separate thread. This session will have some default runspace created but you can change it to another one. Unlike Start-Process (separate process) and Start-Job (child process), [Powershell]::Create() is running on the same process with your main script and sharing memory space with it. This means that you can exchange actual .net objects between the main and child sessions. If sessions run on separate processes they can only exchange with textual/serialized data.
这篇关于PowerShell中的流程vs实例vs Runspace的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!