2
如何创建新线程并在异步中运行?我有一个事件应该在运行时更新文本框,所以我需要在不同的线程中运行它。 (powershell 2)。 如何在PowerShell中执行此操作?在新线程powershell中调用函数
如何创建新线程并在异步中运行?我有一个事件应该在运行时更新文本框,所以我需要在不同的线程中运行它。 (powershell 2)。 如何在PowerShell中执行此操作?在新线程powershell中调用函数
背景工作是你在找什么。
http://msdn.microsoft.com/en-us/library/dd878288(VS.85).aspx
下面是帮助几个例子:
开始有启动作业的作业:
C:\PS>start-job -scriptblock {get-process}
Id Name State HasMoreData Location Command
--- ---- ----- ----------- -------- -------
1 Job1 Running True localhost get-process
开始与AsJob参数工作:
C:\PS>$jobWRM = invoke-command -computerName (get-content servers.txt) -scriptblock {get-service winrm} -jobname WinRM -throttlelimit 16 -AsJob
作为如果您提供一些代码示例,我可以在我的答案中添加一些示例代码。 – 2010-09-14 16:25:03
您也可以使用Powershell事件来执行此操作,该事件在事件发生时执行操作。这只是意味着你不必担心其他线程/工作等 – RC1140 2010-09-16 15:48:59