Docs

In-depth how-to’s on PoshGUI features

WPF – Multithreading

 

It is really easy to execute a background job while still being able to update the UI using DataContext

    • Step 1: Turn on the multithreading toggle on the output page
      It will add boilerplate for managing background tasks

 

  • Step 2: In your event, pass a script block to an Async function like this:
    
            function OnClickEvent(){ #example event 
    
                Async {
                    perform-longFuction  
                    $State.status = "Done" 
                }
    
            }
    
            

 

You can still update the UI using the $State object in another thread, without worrying of freezing the UI
You don’t need to clean up finished background tasks, it is done automatically