0

I have a Powershell GUI, and there are a couple of Checkboxes the user can click ,a Button and a TextBox. If the button is clicked the functions starts working and does a lot of copying renaming etc...

When each "section" is done (like copying a .zip file) I Append a to the Textbox, heres how my program looks like:

$button.Add_Click({Test})

function Test{
"some zip copying code"
$TextBox.AppendText("'r'n ZIP file copied...")

"some renaming code"
$TextBox.AppendText("'r'n File succesfully renamed..")
}

If i press the button the whole program freezes and if done, it prints all "messages" at once. How can i do a threding in it so that the program wont freeze, and when a section is done, it prints to the textbox?

AnyamBorogass
  • 281
  • 1
  • 15
  • 1
    Have a look here: https://stackoverflow.com/questions/65530666/powershell-gui-freezing-even-with-runspace – Scepticalist May 19 '21 at 09:21
  • Does this answer your question? [Powershell GUI Freezing, even with runspace](https://stackoverflow.com/questions/65530666/powershell-gui-freezing-even-with-runspace) – T-Me May 19 '21 at 09:28
  • WinForms or WPF? However @Scepticalist is right there exists a lot of questions to this topic – T-Me May 19 '21 at 09:30
  • @Scepticalist I'm still struggling with this simple thing, tried everything in the link you provided, but somehow its still not working... I'm clearly missing something, or not understanding properly.. Can any of you please create a simple example for this specific question. Would really appreciate it! (WinForm) – AnyamBorogass May 20 '21 at 09:07
  • @T-Me Still struggling, can you please provide example. Would really appreciate it! :( – AnyamBorogass May 20 '21 at 09:08
  • @AnyamBorogass take a look [here](https://hinchley.net/articles/creating-a-windows-form-using-powershell-runspaces/) and [here](https://learn-powershell.net/2013/04/19/sharing-variables-and-live-objects-between-powershell-runspaces/). A single Runspace should suffice. No need for a Runspace Pool. – T-Me May 20 '21 at 10:19

0 Answers0