How to run function without freezing WinForms UI?

Hi,

I’ve been looking for an explanation of how to run a function from PoshPT VSCode WinForms without it freezing up the UI. I saw runspaces mentioned but I’ve not had any luck getting this to work. I also saw a link Adam added to one response but the link is not dead. Would it be possible to have a template or quick YouTube video made of how to do this with PoshPT? I also checked YouTube but the explanations are not PoshPT specific and do not work with PoshPT. Or most likely I just don’t know what I don’t know and I’m doing something wrong.

So to recap, what I’m looking to do is:

  • Create a PoshPT WinForms app
  • Create a long running function
  • Run that long running function in the background so it does not lock up the UI
  • Have the function return results to the UI and update multiple labels or textboxes with the returned information.
1 Like