Close application gracefully

Topics: CAB & Smart Client Software Factory
Jan 27, 2006 at 7:25 AM
originally posted by: markvinsant

I am authorizing the user to use the application when my main workitem is Run. Is there any way to stop the application gracefully if the authorization fails? Application.Exit() is completely ignored, terminating the workitem, its parent, and so forth causes the shell to break, and closing the shell form directly also breaks the CABShellApplication. When I say "breaks", I mean at some point it attempts to reference an object that has already been disposed.
May 16, 2006 at 6:10 AM
originally posted by: cvbiju

Did you find a way out ?
May 19, 2006 at 2:47 AM
originally posted by: DLorenz

One way would be to put your code check in the ShellApplication (the one that inherits from FormApplication). Do your check and if it fails, don't actually run the App at all. You could display a message box aas to why nothing ran, if you wanted to.

If you need the WorkItem to start, then you could do a couple of other things. The least amount of code would be simply using the EventBroker to tell the shell to use Application.Exit(). I don't think you can use Application.Exit() directly on a WorkItem. It may have to be called from a Form or UserControl/SmartPart because Application.Exit() works fine for me when run on the Shell.
Jun 3, 2006 at 1:14 AM
originally posted by: icars

this.RootWorkItem.Terminate() works for me.