Showing tag results for Code

Sep 10, 2010
Post comments count0
Post likes count1

Hey there token, long time no see! (Did you do something with your hair?)

Raymond Chen
Raymond Chen

Consider a system where you have a lot of secured objects, and suppose further that checking whether a user has access to an object is a slow operation. This is not as rare as you might think: Even though a single access check against a security descriptor with a small number of ACEs might be fast, you can have objects with complicated security des...

Code
Sep 9, 2010
Post comments count0
Post likes count0

Flushing your performance down the drain, that is

Raymond Chen
Raymond Chen

Some time ago, Larry Osterman discussed the severe performance consequences of flushing the registry, which is a specific case of the more general performance catch: Flushing anything will cost you dearly. A while back, I discussed the high cost of the "commit" function, and all the flush-type operations turn into a commit at the end of the day...

Code
Sep 3, 2010
Post comments count0
Post likes count0

What happens to a named object when all handles to it are closed?

Raymond Chen
Raymond Chen

A customer had a question about named kernel objects: I understand that handles in a process if leaked will be destroyed by the kernel when the process exits. My question would be around named objects. Would named objects hold their value indefinitely? If I run a small utility app to increment a named counting semaphore, the count of that named...

Code
Aug 26, 2010
Post comments count0
Post likes count0

How do I recover the window handle passed to ShellExecute?

Raymond Chen
Raymond Chen

A customer had the following question: I'm using the function to launch a new process and am passing the handle to my application's main window as the parameter. From the new process, I want to get information from the old process, and to do that, I need the window handle. How can I recover that window handle from the new process? You can't. ...

Code
Aug 23, 2010
Post comments count0
Post likes count0

Be careful that your splash screen doesn't squander the foreground love

Raymond Chen
Raymond Chen

Commenter Erbi has a program which creates a splash screen on a background thread while the main thread initializes. "I create and then destroy this splash screen window just before creating and displaying the main window." The problem is that the main window fails to obtain foreground activation. Commenting out the code that creates the splash scr...

Code
Aug 13, 2010
Post comments count0
Post likes count0

When do I need to use GC.KeepAlive?

Raymond Chen
Raymond Chen

Finalization is the crazy wildcard in garbage collection. It operates "behind the GC", running after the GC has declared an object dead. Think about it: Finalizers run on objects that have no active references. How can be a reference to an object that has no references? That's just crazy-talk! Finalizers are a Ouija board, permitting dead objec...

Code
Aug 12, 2010
Post comments count0
Post likes count0

How can I find all objects of a particular type?

Raymond Chen
Raymond Chen

More than one customer has asked a question like this: I'm looking for a way to search for all instances of a particular type at runtime. My goal is to invoke a particular method on each of those instances. Note that I did not create these object myself or have any other access to them. Is this possible? Imagine what the world would be like if...

Code
Aug 6, 2010
Post comments count0
Post likes count0

Some known folders cannot be moved, but others can, and you'll just have to accept that

Raymond Chen
Raymond Chen

Locations in the shell known folder system can be marked as , which makes them immovable. Conversely, if a file system folder is not immovable, then it can be moved. This dichotomy appears simple and unworthy of discussion, except that customers sometimes have trouble incorporating this concept into their world view. I have some code that calls...

Code