开发者

Invoke function in new thread powershell

开发者 https://www.devze.com 2023-01-15 22:38 出处:网络
How can i create new thread and running in async? i have an event which should update text box in run t开发者_运维技巧ime so i need to run it in different thread.

How can i create new thread and running in async? i have an event which should update text box in run t开发者_运维技巧ime so i need to run it in different thread. (powershell 2). How can i do it in PowerShell?


Background Jobs are what you are looking for.

http://msdn.microsoft.com/en-us/library/dd878288(VS.85).aspx

Here's a few examples from help:

Starting a job with Start-Job:

C:\PS>start-job -scriptblock {get-process}

Id    Name  State    HasMoreData  Location   Command
---   ----  -----    -----------  --------   -------
1     Job1  Running  True         localhost  get-process

Starting a job with the AsJob parameter:

C:\PS>$jobWRM = invoke-command -computerName (get-content servers.txt) -scriptblock {get-service winrm} -jobname WinRM -throttlelimit 16 -AsJob
0

精彩评论

暂无评论...
验证码 换一张
取 消