简体   繁体   English

使用Powershell在后台运行功能

[英]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.

相关问题 在 Powershell 中运行 886982359588 中的 IF 语句 - Running IF Statements in a Function in Powershell 在要求更多输入的同时在后台运行函数 - Running a Function in the background while asking for more inputs Chicken-And-Egg-Situation:Function 用于在后台运行命令 - Chicken-And-Egg-Situation: Function for running commands in the background 在多个 div 上运行 jQuery 函数(从 img 标签获取背景图像并使用 CSS 将其应用为部分背景) - Running a jQuery function on multiple divs (getting background image from img tag and applying it as section background using CSS) 如何在Powershell脚本中检查功能依赖性。 避免多次运行同一功能 - How to check for functions dependency in powershell scripts. Avoid running the same function multiple times PowerShell ISE中的Powershell函数行为 - Powershell function behavior in PowerShell ISE 即使浏览器在后台运行,如何使 Javascript Timeout function 运行? - How to make Javascript Timeout function run even when browser is running in background? Powershell将变量传递给函数 - Powershell Passing Variable to Function Powershell功能+字典 - powershell function + dictionary 使工作流程发挥作用-Powershell - Make function for workflow - Powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM