[英]Running a function in background with Powershell
I want to run a function Get_List in the background and while it's running, the screen should show "Searching for Information" + dots to make it look like work is being completed. 我想在后台运行功能Get_List,并且在运行时,屏幕上应显示“正在搜索信息” +点,以使其看起来好像工作已完成。
function Get_List {
#Some basic command to run in the background
}
. 。
function Other{
#start the Get_List function in background
while(Get-Job -State "Running")
{
#show "Searching for Information"
#no need to code this part for me
}
}
I have seen many people with similar questions, but mine (I think) is a bit different. 我见过很多人有类似的问题,但是我的(我认为)有些不同。 No parameters are being passed, I just want to run something on the background which takes about 5-10 seconds and when it's done, that's it.
没有传递任何参数,我只想在后台运行一些操作,这大约需要5到10秒钟,完成后就可以了。
I am trying to be as simple as possible. 我正在尝试变得尽可能简单。 Any help is appreciated.
任何帮助表示赞赏。
Simple alternative approach is to use Write-Progress to show your fake or actual progress. 一种简单的替代方法是使用Write-Progress来显示您的伪造或实际进度。 Have a look at https://technet.microsoft.com/en-us/magazine/2008.03.powershell.aspx
看看https://technet.microsoft.com/en-us/magazine/2008.03.powershell.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.