DCSIMG
C# - Manu Cohen-Yashar's Blog

Manu Cohen-Yashar's Blog

Browse by Tags

All Tags » C# (RSS)
TPL Dataflow Resources
"TPL Dataflow (TDF) is a new .NET library for building concurrent applications. It promotes actor/agent-oriented designs through primitives for in-process message passing, dataflow, and pipelining. TDF builds upon the APIs and scheduling infrastructure provided by the Task Parallel Library (TPL) in .NET 4, and integrates with the language support for asynchrony provided by C#, Visual Basic, and F#." If you are using the asynchronous queuing pattern within your process you want to look at...
Asymmetric Encryption with RSACryptoServiceProvider
Traditional symmetric cryptography is all about hiding a secret using an algorithm and a key. The same key is used for encryption and decryption. Asymmetric encryption does much more. In Asymmetric encryption there are two key: one is kept secret (private) and the other is distributed (public). Both keys are mathematically the same – What makes the public key public is the fact that it was distributed. To perform a full cycle both keys are required (i.e. encryption with one key and decryption with...
How to write better code with Code contracts PEX and Moles
When I write code I always ask myself how can I make it better. One of the main steps I take to improve my code is write unit tests and use Asserts. All Code is based on assumptions. (i.e. a variable is not null etc). These assumptions must be validated before the code is executed. We all know that and I hope you all do that but still it happens my that code crushes because an assumption I forgot was not validated. I was looking for something to help be to improve my code and then I heard about PEX...
Data Contract topology in WCF 4.0 - DataContractResolver
In WCF 3.x, type resolution was done using the “known types” mechanism. During deserialization, when the serializer encounters an instance that isn’t of the same type as the declared type, it inspects the list of declared “known types” to figure out what type to use. As the author of the service, you could annotate your types/methods with the [KnownType] or [ServiceKnownType] attributes to define the list of possible substitutions. (in code or config) Unfortunately, WCF 3.x doesn’t provide an easy...
Spliting WCF config files
ConfigSource attribute on system.serviceModel section The configSource attribute was firstly introduced in .NET framework 2.0 to support external configuration files. This attribute can be added to any configuration section to specify a an external file for that section. Using an external configuration source can be useful in many scenarios. For instance, you could place a section into an external configSource if you need an easy method to swap settings for the section depending on the environment...
Increase the numbers of threads in the Threat Pool
If you have used the ThreadPool in .NET 1.x, you know that the threadpool defaults to ( 25 * number of processors ) threads per process. It can be changed, but it is kinda complicated to track down how to change this. Well, MS has made changing the threadpool to make this easily changeable. Here is some example code: ThreadPool .GetMaxThreads( out iMaxThrds, out iThrdCompletionPT); ThreadPool .SetMaxThreads( Environment .ProcessorCount * 50, iThrdCompletionPT); ThreadPool .GetMaxThreads( out iMaxThrds...
Serializable Dictionary
Serializable Dictionary I wanted to use a dictionary<T> to create a MSMQ message but I found that a dictionary is not serializable. I spoke to a good friend “Adar Wesley” and he gave me the code of a Serializable Dictionary<T> he wrote. So here it is. Enjoy. Download: SerializableDictionary