Posts

Multithreaded Programming

Synchronization primitives Semaphore Slim

Wait Many

IAsyncResult needs to be closed.

Hashing for collection's keys

Key objects must be immutable as long as they are used as keys in the Hashtable. When an element is added to the Hashtable, the element is placed into a bucket based on the hash code of the key. Subsequent lookups of the key use the hash code of the key to search in only one particular bucket, thus substantially reducing the number of key comparisons required to find an element. GetBucket(item. GetHashCode ()) Any object that creates a hashvalue should change the hashvalue, when the object changes, but it must not - absolutely must not - allow any changes to itself, when it is used inside a Hashtable (or any other Hash-using object, of course). So, just make GetHashCode result change, when the object data changes, and if the use of the object inside of hash using lists or objects is intended (or just possible) then make the object either immutable or create a readonly flag to use for the lifetime of a hashed list containing the object. (By the way: All of this is not C# oder...

Choosing Collections in .NET Framework

(In progress...) Big O Notation     http://stackoverflow.com/questions/2307283/what-does-olog-n-mean-exactly . The Generic Collections: System.Collections.Generic namespace     Associative Collection Classes (stores a value by a key, associates the value with the key)         useful to lookup/manipulate a collection using a key value         The Dictionary<TKey,TValue>             Best for high performance lookups.                 is the fastest class for associative lookups/inserts/deletes because it uses a hash table under the covers                 The speed of retrieval depends on the quality of the hashing algorithm of the type specified for TKey.   ...

Dependency Properties' key features

In progress... The purpose of dependency properties is to provide a way to compute the value of a property based on the value of other inputs. Main features: Reduced memory footprint   90% of the properties of a UI control typically stay at its initial values   The default values are stored once within the dependency property. Value inheritance   Value resolution strategy.     If no local value is set, the dependency property navigates up the logical tree until it finds a value.   Not good practice cause performance impact.   The main example is the DataContext.   Property value inheritance is not the default property system behavior; a property must be established with a particular metadata setting in order to cause that property to initiate property value inheritance on child elements. Change notification   used by the databinding   used by a custom logic Details: Value Precedence   ... Metadata Override...

Binding.Path syntax

All possible things of the Binding's Path See Binding.Path Property - Remarks (MSDN)

Explicit interface implementation Anti-pattern.

Explicit interface definition forces the members to be exposed only when you are working with the interface directly. The main words are: Unexpected Behavior Mostly used: Implementing of several interfaces with the same members required different implementation. Struggle with dependencies (very doubtful). Code with using more derived types knows nothing about interface's members that were implemented explicitly. For example in a ASP.NET MVP (Web Forms) control hide member used by presenter. Work around for having same member with different logic in an interface and its derived class. Some silly protection (by a run-time exception) from using of inappropriate interface members. As an example the array's explicit implementation for the ICollection<T>.Add() that will throw the NotSupportedException "Collection of a fixed size".  Famous drawbacks: It's greasy messy awful coding especially when used without a serious reason. It's definitely n...