16,554
社区成员
发帖
与我相关
我的任务
分享
'--窗体------------------------------
Public NewThread As Thread
Public Delegate Sub InvokeControl()
Dim _InvokeControl As InvokeControl
......
AddHandler 对象.事件, AddressOf 托管方法
处理方法
_InvokeControl = AddressOf 处理方法
NewThread = New Threading.Thread(New Threading.ThreadStart(AddressOf 类.方法))
NewThread.IsBackground = True '设置当前线程为后台
NewThread.Start()
Sub 处理方法
With 对象
.text = "www.i5school.com"
End With
End Sub
Public Sub 托管方法
对象.Invoke(_InvokeControl)
End Sub
'--类------------------------------
Public Class 类
Public Event 事件
Public Sub 方法
...
RaiseEvent 事件 '触发类、窗体或文档中在模块级声明的事件
End Sub
End Class
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub botton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles botton1.Click
Me.Close()
End Sub
Private Sub 朋友买烟(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 我想抽烟
'此处的sender就是我
End Sub
AddHandler 对象.事件, AddressOf 托管方法
AddHandler 我想.抽烟, AddressOf 朋友买烟