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
精彩评论