By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,173 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

Exiting an Application from a class Library

P: n/a
Helo,

My question is how can I exit an application from a class Library...

I've got a class library wich I use to load and save user setting for my
application, some of this settings are mandatory, therefore if the setting
is not present the application should exit. I know I could throw an
exception to the main program, or even return nothing, make a check wich
will close the application if its Nothing. But this means more code on the
program side, and I would like to relief the program code from this checks
passing them to the class library (after all the class was made in order to
realieve coding and coding errors in case you forgot a check).

I've tried passing the "application" 'class' to the class inside my class
library, but .NET will say it's a type and it can't be passed as a
parameter, therefore "application.exit" seems to be unaccesible from my
class library.

What could I do to close the application from the class library?

Thanks in advance,

Juan
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Nice Posting Juan,

here is the code:

Public Class LoadSettings
Delegate Sub ApplicationExit()

Public Shared Sub LoadSettings(ByRef CallThisFunction As
ApplicationExit)
CallThisFunction.Invoke()
End Sub

End Class

Call it this way

LoadSettings.LoadSettings(New LoadSettings.ApplicationExit(AddressOf
Application.Exit))

Hope it works. :)

Juan Pedro Gonzalez wrote:
Helo,

My question is how can I exit an application from a class Library...

I've got a class library wich I use to load and save user setting for my
application, some of this settings are mandatory, therefore if the setting
is not present the application should exit. I know I could throw an
exception to the main program, or even return nothing, make a check wich
will close the application if its Nothing. But this means more code on the
program side, and I would like to relief the program code from this checks
passing them to the class library (after all the class was made in order to
realieve coding and coding errors in case you forgot a check).

I've tried passing the "application" 'class' to the class inside my class
library, but .NET will say it's a type and it can't be passed as a
parameter, therefore "application.exit" seems to be unaccesible from my
class library.

What could I do to close the application from the class library?

Thanks in advance,

Juan


--

Best,
_____________
Bharat Sharma

* TEN Technologies.
* Official Web: _www.ten-technologies.com_
<http://www.ten-technologies.comemail/>
Personal Web: _www.bharatsharma.net_ <http://www.bharatsharma.net/>

Nov 21 '05 #2

P: n/a
Thank you Bharat, It work perfectlly! :)

"Bharat Sharma" <bh****@bharatsharma.net> escribió en el mensaje news:uz**************@tk2msftngp13.phx.gbl...
Nice Posting Juan,

here is the code:

Public Class LoadSettings
Delegate Sub ApplicationExit()

Public Shared Sub LoadSettings(ByRef CallThisFunction As ApplicationExit)
CallThisFunction.Invoke()
End Sub

End Class

Call it this way

LoadSettings.LoadSettings(New LoadSettings.ApplicationExit(AddressOf Application.Exit))

Hope it works. :)
--

Best,
_____________
Bharat Sharma

TEN Technologies.
Official Web: www.ten-technologies.com
Personal Web: www.bharatsharma.net

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.