如果我有这样的事件:
' <summary>
' Event raised when conversion progress changes.
' </summary>
Public Shared Event PercentDone(ByVal percent As Integer)
Sub(...)
CoreConverter.StartInfo.FileName = CoreConverter_Location
CoreConverter.Start()
While Not CoreConverter.HasExited
If ChrW(CoreConverter.StandardOutput.Read) = "*" Then
progress += 1
RaiseEvent PercentDone(progress)
End If
End While
CoreConverter.Close()
RaiseEvent Exited()
End sub
我如何在其他类(例如默认的 Form1 类)中编写事件处理程序,如下所示:
Sub Converter_Progress(Progress As Integer) Handles CoreConverter.PercentDone
' Some code...
End Sub
...而不是像这样手动添加处理程序:
AddHandler CoreConverter.PercentDone, AddressOf Converter_Progress