PowerShell Pro Tools GUI Freezes

When creating a powershell gui in Visual Studio, how do i make it not freeze when running a function with a button click.

I have tried with start-job, which i can get to work, but if i also need to function to change a label or a textbox this wont work.

think you need to use runspaces, to makeit multi threaded, ive the same issues and have asked about how to incorporate runspaces before but ultimately drawn a blank

Something is wrong with the images in this post but you can use ThreadJob to run background runspaces without having to setup all the runspaces: https://ironmansoftware.com/using-the-threadjob-powershell-module-to-run-background-tasks-in-windows-forms/