2010年7月28日 星期三

Application.Run 方法 (Form)

這code 待研究,因我未用過;記錄起來
-----------------------
.NET Framework 类库
Application.Run 方法 (Form)

在当前线程上开始运行标准应用程序消息循环,并使指定窗体可见。

命名空间:System.Windows.Forms
程序集:System.Windows.Forms(在 system.windows.forms.dll 中)


VB.NET code

'---------------------------------
Sub Main()
AddHandler g_ManageCmd.MsgRecv, AddressOf frmMain.lvwMsgManager_UpdateInvoke


'在当前线程上开始运行标准应用程序消息循环()
'Application.Run(New frmMain)
Application.Run(frmMain)

End Sub

'-------------------------------------------------------
'专门处理来自客户端消息的类,由sokcet.DataArrial()事件触发
'来自客户端的消息处理
Public Sub InfoFromClientHandler(ByVal ID As Integer, ByVal cmd As strtManageCommand)
'需要弹出提示窗口,具体的内容从缓冲区中获取,弹出窗口不能影响其他程序的执行,不能
'在当前线程上启动
RaiseEvent MsgRecv()

End Sub

'--------------------------------------------------------
'主窗体中,定义处理界面的委托和处理具体事件客户端信息来临时的事件MsgRecv
'委托
Public Delegate Sub lvwMsgManager_Invoke()

'更新
Public Sub lvwMsgManager_UpdateInvoke()
If Me.InvokeRequired Then
Me.Invoke(New lvwMsgManager_Invoke(AddressOf Me.lvwMsgManager_UpdateInvoke))
Else

Try
lvwMsgManager_Update()
Catch ex As Exception
ErrorHandler(ex.ToString)
End Try
End If
End Sub

沒有留言:

張貼留言