Say you have an event raiser method (OnXXX) that raises an event using the CancelEventArgs class is there anything wrong with having the OnXXX method return the value of e.Cancel?
For example:
Public Sub ProcessFiles(folder as DirectoryInfo)
For each file in folder.GetFiles()
If OnProcessingFile(New FileEventArgs(file)) Then
.....ProcessFileCode
Else
Exit For
End If
Next
End Sub
Protected Function OnProcessingFile(ByVal e As FileEventArgs) As Boolean
RaiseEvent ProcessingFile(Me, e)
Return Not e.Cancel
End Function
Seems to me to be a cleaner solution than this:
Public Sub ProcessFiles(folder as DirectoryInfo)
Dim e As FileEventArgs
For each file in folder.GetFiles()
e = New FileEventArgs(file)
OnProcessingFile(e)
If e.Cancel Then
Exit For
End If
.....Process File Code
Next
End Sub