LA.NET [EN]

May, 2009Archive

May 28

As we’ve seen in the last post of the series, we can use the thread pool for scheduling several “types” of asynchronous operations and to amortize the penalty we pay when we need to create extra threads. In fact, I’d say that most operations should be performed by using a thread from the thread pool. […]

Read the rest of this entry »

May 28

VS 2010 color scheme patch

Posted in C#, VS       Comments Off on VS 2010 color scheme patch

If you enjoy dark themes and love VS 2010, then you know you’re into trouble. The problem is that VS looses the dark background after being closed and you need to go to the options, fonts and colors and then apply the current settings (which still have the correct color) again. The good news is […]

Read the rest of this entry »

May 28

Downloading .NET reflector

Posted in Trivia       Comments Off on Downloading .NET reflector

Not sure on how I should classify this, but I’d say that getting this error in 2009 from a page served by a company like redgate is incredible! Today I needed to download reflector, so I went to redgate’s site and chose the download option. When you do that, you’ll be redirected to a page […]

Read the rest of this entry »

May 27

Until now, we’ve been starting threads by creating instances of the System.Threading.Thread class in the samples. Thread creation isn’t cheap! If we’re creating a thread just to run a small task, then the thread’s creation might completely outweigh the advantage of running such a small task. In most cases, instead of creating new threads, we […]

Read the rest of this entry »

May 27

Protected: Using condition variables

Posted in C#, Multithreading       Comments Off on Protected: Using condition variables

There is no excerpt because this is a protected post.

Read the rest of this entry »

May 27

Multithreading: condition variables

Posted in C#, Multithreading       Comments Off on Multithreading: condition variables

There are times when a thread needs to wait  for a specific condition to be true. Since this condition tends to involve shared state, then you know that you must use some sort of synchronization to ensure proper update of the data used by the condition. When we looked at kernel objects, we’ve seen that […]

Read the rest of this entry »

May 27

C question from Dan Garcia

Posted in Trivia       Comments Off on C question from Dan Garcia

Currently, I’m following Dan Garcia’s CS61C course (which is freely available online). On lesson 6, there’s an interesting puzzle (which, btw, I got it wrong – I’ll tell you why on the next post). The question is: which snippets prints always 5? 1,,) main() {    int *a-ptr; *a-ptr = 5; printf(“%d”, *a-ptr); } 2) […]

Read the rest of this entry »

May 26

Sheer mind power!

Posted in Trivia       Comments Off on Sheer mind power!

This is not a technical post, so if you’re not interested, just skip it! Here’s the deal: a few days back, my good friend Filipe (aka, “super-loide” – long story, ok? but he knows why he’s called that:),,) started laughing when I said that I would reach the 10km mark on my treadmill. His words: […]

Read the rest of this entry »

May 26

In the previous posts, we’ve seen how we can use monitors and any CLR object for getting a critical region. Whenever you need to get a critical region, using a CLR lock for ensuring proper access. However, there will be times when, for instance, you’ll have much more reads than writes. In these cases, using […]

Read the rest of this entry »

May 26

Type parameters on Func delegates

Posted in C#       Comments Off on Type parameters on Func delegates

Eric Lipert has another very interesting entry which explains why the team decided to use the last type parameter as the return value of a Func compatible delegate. I think that Eric should put his thoughts on a book so that I could read everything all over again while I’m on the bus. What I’m […]

Read the rest of this entry »

May 25

Multithreading: more on CLR locks

Posted in C#, Multithreading       Comments Off on Multithreading: more on CLR locks

In the previous post we’ve taken a quick peek at how we can use the CLR lock primitive. In this post we’re going to talk about some interesting things you might need to know when you work with these locks. According to Joe’s reference, the CLR locks use some spinning internally before waiting on a […]

Read the rest of this entry »

May 25

When we looked at the kernel objects, we’ve seen that we could use a mutex to achieve critical regions. Whenever we need to build a critical section, we should use the CLR locks instead of relying directly on mutexes. In .NET, any object can be used as a lock when you need to build a […]

Read the rest of this entry »

May 24

Multithreading: synchronization primitives

Posted in Multithreading       Comments Off on Multithreading: synchronization primitives

In the latest posts, we’ve taken a look at several kernel objects which we can use for data and control synchronization. Today we’re going to start looking at the synchronization primitives. These structures should always be used (whenever possible, of course) instead of the kernel objects we’ve met in previous posts. Why? Because they’re cheaper. […]

Read the rest of this entry »

May 22

Multithreading: signaling and waiting

Posted in C#, Multithreading       Comments Off on Multithreading: signaling and waiting

2011-01-12 13:12:03

Read the rest of this entry »

May 21

Multithreading: waiting on kernel objects

Posted in C#, Multithreading       Comments Off on Multithreading: waiting on kernel objects

Until now, we’ve seen how we can wait on several synchronization kernel objects until a specific condition is met. All the examples we’ve seen ended up using the simple WaitOne method.Today we’re going to take a look at the other “waiting” methods inherited from the base WaitHandle class: WaitAny and WaitAll. You’ll need these static […]

Read the rest of this entry »

May 20

Multithreading: “interrupting” threads waiting

Posted in C#, Multithreading       Comments Off on Multithreading: “interrupting” threads waiting

Ok, now that we’ve seen the basic kernel synchronization objects that you can use in .NET programming, I guess that it’s a good time to talk about how we can wake up a waiting thread without signaling the kernel object on which the thread is waiting for. In .NET, any blocked thread can be awakened […]

Read the rest of this entry »

May 19

Wonderful news!

Posted in Trivia       Comments Off on Wonderful news!

Currently, I’ve got three wonderful cats. Luna, a cat that I’ve found in the street when she was two months old, got really sick in the last months…in fact, the vet had told us to get ready because her liver problems wouldn’t let her live much longer. All her blood tests returned some pretty bad […]

Read the rest of this entry »

May 19

[If you’ve just seem a one post sentence, then you’re probably seeing the first Luna’s post :,,) . She has just managed to publish a one line post while I was checking what was on the TV:)] In the previous post, we’ve taken a quick glance at how we can use the ManualResetEvent. At the […]

Read the rest of this entry »

May 19

Windows API Code Pack for .NET

Posted in C#, Windows 7       Comments Off on Windows API Code Pack for .NET

Just noticed this package that should be useful for all .NET developers that want to use the new Windows 7 features.

Read the rest of this entry »

May 19

Multithreading: ManualResetEvent events

Posted in C#, Multithreading       Comments Off on Multithreading: ManualResetEvent events

2011-01-12 13:11:31

Read the rest of this entry »

May 18

Multithreading: using AutoResetEvents

Posted in C#, Multithreading       Comments Off on Multithreading: using AutoResetEvents

After the introductory theory associated with events, it’s time to take a look at how we can use an AutoResetEvent for synchronizing access to a protected resource. The first thing we need to do to start using an AutoResetEvent is getting a reference to a valid instance of this type. We can get one by […]

Read the rest of this entry »

May 18

More on extension methods

Posted in C#       Comments Off on More on extension methods

I’ve already posted about this topic in the past. However, it looks like there are still some people which don’t take full use of this new (ok, not so new anymore!") cool feature. In my opinion, extension methods are great and they end up simplifying (a lot) the code we need to write. If you’ve […]

Read the rest of this entry »

May 18

Multithreading: using events

Posted in C#, Multithreading       Comments Off on Multithreading: using events

Windows OS offers two kinds of events: auto and manual-reset events. As you might expect by now, any event can be in a signaled or non-signaled state (after all, both of these events are kernel objects). Instead of using signaled and non-signaled terms, you’ll probably hear the words set and reset when talking about these […]

Read the rest of this entry »

May 17

In the previous post we’ve seen several concepts associated with semaphore usage. In this post we’re going to see some code that shows how to use this synchronization kernel object. Creating a new semaphore is accomplished through one of the existing constructors: public Semaphore(int initialCount, int maximumCount); public Semaphore(int initialCount, int maximumCount, string name); public […]

Read the rest of this entry »

May 16

Book review: 97 Things Every Software Architect should know

Posted in Books       Comments Off on Book review: 97 Things Every Software Architect should know

It was only yesterday that I’ve finished reading this book which consists on several essays written by different software architects on the super interesting topic that is Software Architecture. Overall, it’s an interesting book with lots of good advice. Perhaps even more important is the fact that all of the essays are 2 pages long […]

Read the rest of this entry »

May 15

Getting started with Server 2008 R2

Posted in Server 2008       Comments Off on Getting started with Server 2008 R2

Interesting post which presents several important info on how to get started on Server 2008 R2.

Read the rest of this entry »

May 15

Multithreading: Semaphores

Posted in Multithreading       Comments Off on Multithreading: Semaphores

This post is all about theory…you’ve been warned :,,) Semaphores have different usage semantics than mutexes. A thread can perform two operations over a semaphore: you can run a put or a take. Internally, the semaphore maintains a count of the numbers of takes and puts through the use of a counter: whenever a thread […]

Read the rest of this entry »

May 15

Multithreading: “sharing” mutexes

Posted in C#, Multithreading       Comments Off on Multithreading: “sharing” mutexes

In the previous post, we’ve looked at some important features provided by the Mutex kernel object. Today we’re going to keep looking at mutexes and we’ll take a look at how we can create named mutexes and use them for synchronizing access to shared state. true that using kernel objects has costs: when you wait, […]

Read the rest of this entry »

May 14

Ok, now that we understand the basics of waiting on a kernel object, it’s time to keep going and start looking at some code (hurray!). Today we’re going to take a look at the mutex kernel object. In .NET, a mutex kernel object is represented by an instance of type Mutex. As we’ve seen yesterday,  […]

Read the rest of this entry »