Looping Forever in a Windows Forms Application

后端 未结 4 558
误落风尘
误落风尘 2020-12-30 15:59

I am using Visual C# sand I\'m using a Windows Form rather than a console application. Therefore I\'m not working in Main (), but rather in the Form File. I\'m also very new

4条回答
  •  醉酒成梦
    2020-12-30 17:01

    Why do you need it to keep looping forever?

    The interesting thing to point out here, is that your program does this anyway; it's called the message loop. It is continuously receiving messages, as the user interacts with it (clicks buttons etc.)

    What are you actually trying to do? There is certainly already a construct that will do what you are looking for, be it a Timer, BackgroundWorker, etc.

    To listen on a TCP socket, there is the TcpListener class. You could fire up a thread for the TCP listener to run in.

提交回复
热议问题