|
If you have a class that you don't want somebody to be able to inherit from, mark it as sealed. As the class is marked as sealed, the optimizer can perform certain optimizations such as transform virtual function member invocations into non-virtual invocations.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thnx ..
But can u explain it more with example .........
|
|
|
|
|
Why? I've explained it and now you have enough information to look it up on google. It's your friend, so use it.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Why is it all these people treat Google like it's the "secret ingredient" that no experienced developer ever mentions in their problem solving recipe??
|
|
|
|
|
I guess that Google's marketing isn't up to much because these idiots seem to have never heard of it.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I don't know who voted you a one for that. But I've countered it.
|
|
|
|
|
Thanks. I hope it wasn't the marketing guys at Google.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Well which part don't you understand?
With a normal class you can inherit it.
If you mark a class as sealed you can't inherit it.
Because the compiler knows it won't be inherited there are probably run-time optimizations that can be performed that wouldn't work if the class was inherited.
|
|
|
|
|
If you are developing components for third-party developers, then you can use sealed classes to prevent them from deriving from your components. Off the top of my head I can think of two reasons for doing this.
1. Quailty Assurance Time - If your class supports being derived, then you should really test it and make sure there are not any problems.
2. Support Time - If you allow your class to be derived, then you will inevitably get support requests.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
The others have posted good answers, but I'll mention that you shouldn't use sealed very much. Every once in a while I'll come across a class from which I want to derive, but is sealed, leaving me wondering, "Why the heck did they seal it? No harm can come from my extending it."
I just took a look in my largest solution, which includes my main library, and found that 56 of 309 classes (18%) are sealed, most of them are in the set: { EventArgs , Attribute , Form }
I suggest you not throw sealed on every class you write.
|
|
|
|
|
Hello,
I am reading some settings from config file and save back in case of any modification.
I am restarting the application by Application.Resatart() to read all the settings if modified.
The problem is that while restarting the application it comes to Form_closing event only once abd don't kill the main process as well.
So next time u are restarting the application it won't come to the Form_closing event again.
I need to terminate some threads in closing events.... So how should i do it???
Is their any other way to restart the application???
Thanks.
|
|
|
|
|
What if you hold a boolean that states IsRestart
than instead of Application.Restart() you put Close()
And in the closing event you do your stuff and you check the IsRestart
if true, than do Application.Restart()
Try it out, because i am not sure if it will work.
|
|
|
|
|
I have a project in school where in I need to disable the task manager, and the special keys like Alt+F4, Ctrl+Alt+Del, etc... but I don't know how using C#.net... Is there anyone who could help me???
|
|
|
|
|
redangel1522 wrote: I have a project in school where in I need to disable the task manager, and the special keys like Alt+F4, Ctrl+Alt+Del
I seriously doubt the truthfullness of this statement. What is the purpose of this program?
|
|
|
|
|
our project is to make an internet Cafe program where in the client computer will only be usable everytime the server computer gave the permission... when the client is not in use, there is a program that runs which will be closed only by the server, I need to disable the task manager and the keys of the client... please help me...
|
|
|
|
|
I think that this normally is done by using security policies. And if you can do it through Active Directory, the better (central management).
What for your own application.
You can intercept the Form.Closing event and do e.Cancel = True; Than the form will not be closed, but of course you need to have a mechanism to close the app eventually (Read: when you decide it)
|
|
|
|
|
but the application can still be closed by the user using the task manager, is there a way for me to restrict that???
|
|
|
|
|
Well, if you read again my statement. Using the group policy objects you can disable the task manager from opening.
do for example start run gpedit.msc
go to: User config - Admin templ - System - Ctrl+Alt+Del options
You will find this:
Setting State
Remove Task Manager Not configured
Remove Lock Computer Not configured
Remove Change Password Not configured
Remove Logoff Not configured
So, check it out, maybe it is more easy than you think.
|
|
|
|
|
Isn't your school project about finding out for yourself how to do this, and NOT ask someone else to provide a solution for you?
If it' stuck, DO NOT pull harder!
|
|
|
|
|
Yes, i think the same, but he is asking advice and that we can give
|
|
|
|
|
i already tried to look for the solution for this but i didn't find a way for it to be done that's why i'm already asking you guys for help...
|
|
|
|
|
well, if you cant do it with policies:
disable task manager in the registry
http://www.pctools.com/guides/registry/detail/163/[^]
as for other key combinations you probably need some sort of keyhook. there are some articels on that subject here on CP..
but policies are still the best solutions for this. and not so close to the malicioussoftwarezone as keyhooks
If it' stuck, DO NOT pull harder!
|
|
|
|
|
Yehey.. Tnx for the help...
|
|
|
|
|
Hi All,
Can anyone please help me in creating a list like in Microsoft Outllok Undo.
I don't know how can i create a list like this , so if u have any idea please tell me.
Any suggestion would be appreciated.
Thanx.
Praveen Sharma
|
|
|
|
|
There are many articles here on CP about creating your own Undo. In order to do this though, you really need to have a think about the architecture that you are planning to use because this plays a heavy part in the decision of which framework to use. I would suggest that you start by having a look at this[^] article.
Deja View - the feeling that you've seen this post before.
|
|
|
|