locked
Is there a tab Unload type event? RRS feed

  • Question

  • I'm trying to figure out what event/method is called when the Console is shutdown (as in HomeServerConsole.exe being stopped) so I can save my Add-In settings. I've tried putting a call to my own method in the Dispose method but no joy. Anyone know what method I should be using?

    BTW, using the standard WHS Settings approach doesn't fit my needs (e.g. saving menu options) which is why I'm not using it.
    Tuesday, December 30, 2008 10:43 PM

Answers

  • Hmm. Thinking about this a bit more, I'm not sure it's going to work they way you want.

    Resetting the console doesn't appear to fire the event (probably because the reset is just killing the process on the server). Closing the console remotely won't fire the event either; you're just closing the Remote Desktop session there. I haven't checked what happens when the server is restarted.

    The only place it'll get called is if you open/close the console after connecting to the server directly via Remote Desktop.

    Why not save settings after every change? Pretty sure you're serializing out to XML, and that's a pretty low IO task.
    Tentacle Blog: http://www.tentaclesoftware.com/blog/
    WHS Disk Management: http://www.tentaclesoftware.com/WHSDiskManagement/
    Wednesday, December 31, 2008 12:31 AM
    Moderator
  • Try overriding OnCreateControl for your UserControl.

            protected override void OnCreateControl()  
            {  
                base.OnCreateControl();  
                this.ParentForm.FormClosing += new FormClosingEventHandler(ParentForm_FormClosing);  
            }  
     
            void ParentForm_FormClosing(object sender, FormClosingEventArgs e)  
            {  
                MessageBox.Show("Closing!");  
            } 

    Tentacle Blog: http://www.tentaclesoftware.com/blog/
    WHS Disk Management: http://www.tentaclesoftware.com/WHSDiskManagement/
    Wednesday, December 31, 2008 12:21 AM
    Moderator

All replies

  • Try overriding OnCreateControl for your UserControl.

            protected override void OnCreateControl()  
            {  
                base.OnCreateControl();  
                this.ParentForm.FormClosing += new FormClosingEventHandler(ParentForm_FormClosing);  
            }  
     
            void ParentForm_FormClosing(object sender, FormClosingEventArgs e)  
            {  
                MessageBox.Show("Closing!");  
            } 

    Tentacle Blog: http://www.tentaclesoftware.com/blog/
    WHS Disk Management: http://www.tentaclesoftware.com/WHSDiskManagement/
    Wednesday, December 31, 2008 12:21 AM
    Moderator
  • Hmm. Thinking about this a bit more, I'm not sure it's going to work they way you want.

    Resetting the console doesn't appear to fire the event (probably because the reset is just killing the process on the server). Closing the console remotely won't fire the event either; you're just closing the Remote Desktop session there. I haven't checked what happens when the server is restarted.

    The only place it'll get called is if you open/close the console after connecting to the server directly via Remote Desktop.

    Why not save settings after every change? Pretty sure you're serializing out to XML, and that's a pretty low IO task.
    Tentacle Blog: http://www.tentaclesoftware.com/blog/
    WHS Disk Management: http://www.tentaclesoftware.com/WHSDiskManagement/
    Wednesday, December 31, 2008 12:31 AM
    Moderator
  •  Thanks for looking into it Sam. I decided to use a background worker to save the setting after each change. Using a background thread may be overkill but it works pretty well so far.
    Wednesday, December 31, 2008 2:47 AM
  • Using a background process to save settings is a better choice. Resetting the console is intended to allow the end user to regain access when the console becomes unresponsive, and "closing" the console on the client doesn't even close down your Remote Desktop session. It just disconnects from it and closes the client. Then the next time you connect to the console, from any PC, because you're logging in as Administrator again you reconnect to the same session you had going previously, with the console already running. The net effect is that the console "starts" faster, because all you're doing is establishing the remote desktop connection, not actually sterting the app up all over again.
    I'm not on the WHS team, I just post a lot. :)
    Wednesday, December 31, 2008 4:28 PM
    Moderator
  •  
    Ken Warren said:

    Resetting the console is intended to allow the end user to regain access when the console becomes unresponsive, and "closing" the console on the client doesn't even close down your Remote Desktop session.



    Yeah, that's what I meant by "closing the Remote Desktop session". The more precise term I should have used is disconnect.
    Tentacle Blog: http://www.tentaclesoftware.com/blog/
    WHS Disk Management: http://www.tentaclesoftware.com/WHSDiskManagement/
    Wednesday, December 31, 2008 9:26 PM
    Moderator