gooly
gooly

Reputation: 1341

PowerShell gui and the endless program loop?

After the gui works perfectly I am stunned how to integrate it into an endless program loop. The gui is meant to display the status of several socket-connections. So I have:

  1. the gui call PowerShell button click event scriptblock not working GenerateForm
  2. the endless loop that reacts on the orders of the gui and is stopped if the EXIT-button of the gui is clicked.

How do I do that without the gui (GenerateForm) called again and again?

do {
    # write the status lines of the gui...
} until ( <# exit-function of the gui was called #> )

#disconnect, close and dispose..

Upvotes: 1

Views: 520

Answers (1)

Keith Hill
Keith Hill

Reputation: 202032

The ShowDialog() method blocks until the form is eventually closed. Therefore you need to do all your status updating as a result of events firing (inside an event handler). Since the Sockets class seems to be lacking in events, you can set up a WinForms timer event to fire an event handler every 500 millisecs or so to check the socket status.

Upvotes: 2

Related Questions