Browse by Tags

New Security model for .NET 4.0
Mon, Nov 16 2009 11:41
It seems like CLR 4.0 will introduce a new security model (which looks a lot like the one we’ve got in Silverlight). Shawn Farkas has an excellent post which compares the two rule sets and explains what happens in several scenarios. Read More...
by luisabreu | with no comments
Filed under: ,
The global:: qualifier in C#
Thu, Oct 29 2009 13:16
Today I was a little bit surprised when I was asked if we really needed the global:: qualifier. If you’ve been doing C# for some time, the answer is (absolutely) yes. However, things might not be so clear for a beginner (btw, the question was asked in the context of auto-generated by VS which used it to qualify the name of a base class). The best way to understand... Read More...
by luisabreu | 5 comment(s)
Filed under:
NHibernate LINQ is out!
Sun, Jul 26 2009 14:22
Ayende has all the details here . Read More...
by luisabreu | with no comments
Filed under: ,
PT LINQ book mentioned on MVP blog
Tue, Jul 14 2009 12:32
More info here . Read More...
by luisabreu | with no comments
Filed under: , , ,
Multithreading: using VolatileXXX instead of the volatile keyword
Mon, Jul 6 2009 21:25
[Update: Brad detected a flaw in the code: I had forgotten to initialize the _initialized field. Thanks!] [Update2: Brad detected another flaw in the code: return _instance must be outside the if. Thanks!] In the previous post we’ve seen how we can use the C# volatile keyword to guarantee that those nasty load-load reordering stay away from our code. As I’ve... Read More...
Multithreading: the volatile keyword – part II
Mon, Jul 6 2009 9:53
In the last post , I’ve showed you some code I’ve written in  the past and asked if there was anything wrong with it. Here’s the code again: class Lazy { private SomeObject _object; private Object _locker = new Object (); public SomeObject SomeObject { get { if (_object == null ) { lock (_locker) { if (_object == null ) { _object = new SomeObject (); } ... Read More...
Multithreading: using the volatile in your C# code
Sun, Jul 5 2009 21:51
Today we’re only going to talk about the volatile keyword. The volatile keyword can be used on the declaration of a field, transforming it into a volatile field. Currently, you can only annotate a field with this keyword if it is: a reference type; a pointer type (unsafe code); one of the following types: sbyte, byte, short, ushort, int, uint, char, float or... Read More...
Multithreading: a final example on how CompareExchange might help you
Sat, Jul 4 2009 16:31
In the last posts we’ve been poking around memory models, memory fences and other interesting things that might lead to the so called lock free programming. Before keep looking at how we can use those features from our C# code, I’d like to add one more example that shows how the interlocked operations might help you in the real world. Do you recall our implementation... Read More...
by luisabreu | with no comments
Filed under: ,
Multithreading: using fences from .NET code
Fri, Jul 3 2009 15:28
In the last post , we’ve talked about memory fences. Today we’re going to keep looking at this topic, but we’re turning our attention to coding, ie, we’re going to talk about the options we have to add fences to our classes. In .NET, things are relatively straightforward. Whenever we use one of the interlocked methods we’ve met in the past, we’re adding a full... Read More...
Multithreading: introducing memory fences
Fri, Jul 3 2009 13:58
A few posts back, we’ve introduced the concept of load and store reordering. As we’ve seen, reordering operations exist as a way of improving performance and can be introduced on several levels (starting at compilation time and ending at runtime when the processor executes the instructions). We saw that even though things can get chaotic quickly, there are some... Read More...
Multithreading: when interlocked operations aren’t enough
Thu, Jul 2 2009 15:45
In the previous post , we’ve started looking at interlocked operations. As we’ve seen, interlocked operations are great at what they do but they won’t be usable in all scenarios (ie, don’t think that they’ll solve all your locks problems). To show how things might go awry when using interlocks, I’ll reuse a great example written by Raymond Chen a few years ago... Read More...
Multithreading: introducing the interlocked operations
Thu, Jul 2 2009 12:58
As we’ve seen in the previous post , most processors give us important insurances regarding memory loads and stores. However, even though those insurances are important and can be used in several scenarios, the truth is that they aren’t enough for all real world tasks. Fortunately, most processors also offer a group of interlocked operations which enable atomic... Read More...
Multithreading: hardware atomicity
Mon, Jun 29 2009 22:41
In the previous post , we’ve started looking at memory loads and stores reordering. In this post, we’re going to keep our study and we’re going to introduce atomicity. Atomicity is a really important concept we’ve met in the past. We’ve already talked about it on a higher level: do you recall our discussion on critical regions (and how they’re implemented through... Read More...
Multithreading: load and store reordering
Mon, Jun 29 2009 10:55
Until now, we’ve been busy talking a look at several interesting topics associated with multithreading programming. As we’ve seen, one of the most problematic areas in multithreaded programs is sharing state across multiple threads. As we’ve seen in several posts along this series, we can use a critical regions for ensuring that shared state is accessed by one... Read More...
Multithreading: the BackgroundWorker class
Thu, Jun 25 2009 11:27
In the last posts of the series, we’ve been looking at many important features related to GUIs and multithreading. Today, we’re going to wrap up this topic with the BackgroundWorker class. The previous posts are really targeted at library developers. The truth is that having to implement the EAP pattern  to have asynchronous behavior is simply too much work... Read More...
Multithreading: AsyncOperationManager and AsyncOperation helpers
Wed, Jun 24 2009 12:34
In the last posts , we’ve taken a look at how synchronization contexts help marshal work across threads. Today we’re going to talk about two classes (which we’ve already met in the past when we implemented the EAP) that abstract even further the use of synchronization contexts: I’m talking about the AsyncOperationManager and AsyncOperation classes. Let’s start... Read More...
Eric Lippert on C# “top methods”
Tue, Jun 23 2009 14:33
Another interesting post by the great Eric Lippert . Read More...
by luisabreu | with no comments
Filed under:
Multithreading: windows forms and synchronization contexts
Tue, Jun 23 2009 12:14
In the previous post , we’ve started looking at synchronization contexts. In this post, we’ll take a close look at the widows forms custom synchronization context. Whenever you run a windows form app, you might end up interacting with the WindowsFormsSynchronizationContext . The constructor of this class is responsible for getting a reference to the GUI thread... Read More...
Multithreading: Introducing synchronization contexts
Tue, Jun 23 2009 11:08
In the last post , we’ve seen how to marshal back the results obtained on a secondary thread so that controls are updated on the GUI thread. Today we’re going to start looking at synchronization contexts. Synchronization contexts are abstractions for marshalling between threads. In other words, they abstract those scenarios where you cannot call a method from... Read More...
Multithreading: the ISynchronizeInvoke interface
Mon, Jun 22 2009 20:26
In the last post, we’ve see that multithreading is almost a necessity in GUIs. We’ve also seen that there are some gotchas associated with it: a control can only be updated from the GUI thread. In practice, this means that we’ll need to marshal back the results to the main thread when they’re ready. In .NET, the Windows Forms introduces the ISynchronizeInvoke... Read More...
More Posts Next page »