简体   繁体   中英

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.

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.

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. Have a look at https://technet.microsoft.com/en-us/magazine/2008.03.powershell.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM