1

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..

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Is there another method than ShowDialog() that might be better to display some status variables and set some other variables to 'steer' the endless-prgram-loop?
Not really. You need ShowDialog() because it services the windows message queue otherwise you have to pump messages with something hacky like Application.DoEvents().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.