470,620 Members | 1,792 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,620 developers. It's quick & easy.

If e.Cancel Then Exit Sub in Closing event

I've seen this in example code:

Private Sub Studio_Closing(ByVal sender A..snip.. Handles MyBase.Closing

If e.Cancel Then Exit Sub

....snip...

It would make sense if Windows keeps doing Closing events even after it
receives an e.Cancel=true.

Is that the case?

Does the If make sense?

Can anyone shed some light on this?

Thanks for helpful comments


Nov 21 '05 #1
2 1427

The event is broadcast by the multi-cast delegate just like any other
event. This delegate has no knowledge of the Cancel property or what
it is for. It always sends the event to all subscribed delegates.

Also, there are situations where you have multiple listeners of the
closing event and you want them to all fire off even if one of them
says to cancel.

If what you're doing doesn't need to run if something else cancelled,
then it's good practice to add this check at top of routine.

HTH,

Sam
On Fri, 7 Jan 2005 11:43:26 -0500, " Just Me" <gr****@a-znet.com>
wrote:
I've seen this in example code:

Private Sub Studio_Closing(ByVal sender A..snip.. Handles MyBase.Closing

If e.Cancel Then Exit Sub

...snip...

It would make sense if Windows keeps doing Closing events even after it
receives an e.Cancel=true.

Is that the case?

Does the If make sense?

Can anyone shed some light on this?

Thanks for helpful comments


Nov 21 '05 #2
thanks a lot
"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:22********************************@4ax.com...

The event is broadcast by the multi-cast delegate just like any other
event. This delegate has no knowledge of the Cancel property or what
it is for. It always sends the event to all subscribed delegates.

Also, there are situations where you have multiple listeners of the
closing event and you want them to all fire off even if one of them
says to cancel.

If what you're doing doesn't need to run if something else cancelled,
then it's good practice to add this check at top of routine.

HTH,

Sam
On Fri, 7 Jan 2005 11:43:26 -0500, " Just Me" <gr****@a-znet.com>
wrote:
I've seen this in example code:

Private Sub Studio_Closing(ByVal sender A..snip.. Handles MyBase.Closing

If e.Cancel Then Exit Sub

...snip...

It would make sense if Windows keeps doing Closing events even after it
receives an e.Cancel=true.

Is that the case?

Does the If make sense?

Can anyone shed some light on this?

Thanks for helpful comments

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Carl | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.