views:

68

answers:

4

When working with console applications, Console.Readline relinquishes processing to the UI from the Main thread and only continues when an event, such as the pressing of the enter button is fired. How do I replicate this functionality (With a Window form as the UI in this case) in windows form application?

+2  A: 

You cannot do this directly.

However, you can do it by calling Invoke, as I described here.

SLaks
+1  A: 

Use form.ShowDialog() instead of form.Show()

This will not stop the thread, but it will stop the user from doing other things in the UI until the window is closed.

Danny Varod
A: 

Maybe I did not explain this right. What I would like to do is create a service, listen for connections, once a connection is obtained, I display this information on the windows form and then wait for user to put together a response before sending the response back to the client using the same connection.

Kobojunkie
A: 

Now that you have explained what you want to do...

It would be better to use a BackgroundWorker, keep the GUI active, but disabled and presenting a progress bar + cancel button, until done.

Danny Varod