PowerShell gui和无尽的程序循环?
在gui完美运行之后,我惊讶于如何将其集成到一个无休止的程序循环中。 gui用于显示多个套接字连接的状态。因此,我:PowerShell gui和无尽的程序循环?,powershell,user-interface,Powershell,User Interface,在gui完美运行之后,我惊讶于如何将其集成到一个无休止的程序循环中。 gui用于显示多个套接字连接的状态。因此,我: gui调用GenerateForm 对gui命令作出反应的无休止循环,如果单击gui的退出按钮,该循环将停止 如果不反复调用gui(GenerateForm),我该怎么做 do { # write the status lines of the gui... } until ( <# exit-function of the gui was called #>
GenerateForm
GenerateForm
),我该怎么做
do {
# write the status lines of the gui...
} until ( <# exit-function of the gui was called #> )
#disconnect, close and dispose..
do{
#编写gui的状态行。。。
}直到()
#断开、关闭并处理。。
方法将阻塞ShowDialog()
直到表单最终关闭。因此,您需要在事件触发后(在事件处理程序内)执行所有状态更新。由于Sockets类似乎缺少事件,您可以设置WinForms计时器事件,每隔500毫秒左右触发一个事件处理程序,以检查套接字状态。除了ShowDialog()之外,还有其他方法可以更好地显示一些状态变量,并设置一些其他变量来“控制”无休止的prgram循环吗?不是这样。您需要ShowDialog(),因为它为windows消息队列提供服务,否则您必须使用类似Application.DoEvents()的黑客程序来发送消息。