Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ControlHostService Closing ignores CancelEventArgs.Cancel #14

Closed
ColinCren opened this issue Aug 20, 2014 · 3 comments
Closed

ControlHostService Closing ignores CancelEventArgs.Cancel #14

ColinCren opened this issue Aug 20, 2014 · 3 comments

Comments

@ColinCren
Copy link

I've registered on the IMainWindow Closing Event to throw up a prompt if a document is dirty when the app closes. If I do want to throw up the prompt, I want to cancel the close event and call close myself when I'm done with the save.

However it seems ControlHostService mainForm_Closing sets e.Cancel to the result of !Close overwriting the value I set. I think ln718 needs to be e.Cancel = e.Cancel || !Close();

Does that sound right?

@ColinCren ColinCren reopened this Nov 17, 2014
@ColinCren
Copy link
Author

Also when the mainform does not cancel and an intervening operation closes the mainform, it seems to interrupt the layout saving causing an exception in subsequent loads. My suggested change in the original post fixes that as well.

@Ron2
Copy link
Member

Ron2 commented Nov 18, 2014

Good point, Colin. I'll check in your change shortly. Thanks for the good suggestion.

I assume you made sure that your event handler gets the Closing event before ControlHostService. I wish that the ordering of the listeners didn't matter, but there's no way around that restriction given the IControlHostClient interface. (There's no "CanClose" method.)

@ColinCren
Copy link
Author

In my use case it is.

@Ron2 Ron2 closed this as completed in 8d83c13 Nov 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants