Does a Powershell script using system.managment.automation would still run after its C# host die? -


i want add powershell capabilities c# program , have embedded system.managment.automation.dll assembly reference. have found on stackoverflow 2 ways call powershell scrit c# :

  • using runspaces:

  • not using runspaces:

    powershell powershell = powershell.create(); powershell.addscript("my script"); powershell.invoke(); 

according this website, seems powershell instance tied c# host.

the powershell runtime invoked runspace , will, default, process commands synchronously , deliver results of processing host application can returned user.

furthermore, powershell script uses embedded system.managment.automation.dll assembly , not system-wide one, script logically stop c# host.

does powershell script still run after user close program ? 2 methods ?

ps: want support powershell v2.

let's take in reverse chronology:

what 2 methods ?

there's no such thing running powershell code "not using runspaces".

the simple explanation runspace core prerequisite - name implies, runspace space in powershell code runs.

when do:

powershell powershell = powershell.create() 

a runspace implicitly created , attached powershell instance.

the difference defer control on runspace creation system.management.automation api, rather instantiating yourself.

does powershell script still run after user close program ?

the circumstance under script continue execution after host application has terminated, when connect remote runspace, ie. runspace hosted in process or on computer.

otherwise, runspace (implicit or not) disposed along rest of host application when exits.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -