Browse Blog Posts by Tags

Showing related tags and posts for the Blogs application. See all tags in the site
Sorry, but there are no more tags available to filter with.
  • Multithreading: introducing the event based asynchronous pattern

    In the last posts we’ve looked at several details associated with the use of the APM pattern. Today we’re going to start looking at the second pattern for doing asynchronous work: the event based asynchronous pattern. This pattern was introduced with .NET 2.0 and it targets components that are going...
    Posted to LA.NET [EN] by luisabreu on Tue, Jun 16 2009
    Filed under: Filed under: ,
  • Multithreading: implementing the IAsyncResult interface

    Today we’re going to wrap up our study of the APM pattern by seeing how we can implement the IAsyncResult interface. For those that can’t remember, here’s the interface API again: public interface IAsyncResult{     object AsyncState { get; }     WaitHandle AsyncWaitHandle...
    Posted to LA.NET [EN] by luisabreu on Mon, Jun 15 2009
    Filed under: Filed under: ,
  • Multithreading: understanding the BeginXXX and EndXXX methods

    Now that we’ve looked at the available waiting options for the APM pattern, it’s time to start digging on its internals. This post is all about understanding the work of the BeginXXX and EndXXX methods (which isn’t much, as we’ll see). As we’ve seen in previous posts, the BeginXXX method is responsible...
    Posted to LA.NET [EN] by luisabreu on Sun, Jun 14 2009
    Filed under: Filed under: ,
  • Multithreading: APM and the continuation passing style

    In this post, we’ll take a look at the last option we can use for the rendezvous phase of the APM pattern. This last option is based on the continuation passing style principle. In practice, this means that we need to wrap up the work that should be performed after the async task ends in a closure and...
    Posted to LA.NET [EN] by luisabreu on Wed, Jun 10 2009
    Filed under: Filed under: ,
  • Multithreading: the APM pattern and polling for completion

    In this post we’re going to take a look at how we can use polling to see if an asynchronous task has completed. As we’ve seen , the IAsyncResult instance returned from the BeginXXX method (that started an asynchronous task) has an IsCompleted property that returns true when the task is completed. In...
    Posted to LA.NET [EN] by luisabreu on Wed, Jun 10 2009
    Filed under: Filed under: ,
  • Multithreading: waiting on the APM’s WaitHandle

    Today, we’re going to keep looking at the available options waiting for the conclusion of an asynchronous task started through the APM model. In this post we’re going to see how we can use the WaitHandle which we can get through the IAsyncResult’s AsyncWaitHandle property. After getting a valid reference...
    Posted to LA.NET [EN] by luisabreu on Tue, Jun 9 2009
    Filed under: Filed under: ,
  • Multithreading: blocking the thread by calling EndXXX directly

    As we’ve seen, one of the available options is blocking the thread by calling the EndXXX method directly. This might be a good option when you only need to do one or two small tasks and then you need to wait until the asynchronous operation is completed. In practical terms, this option won’t be usable...
    Posted to LA.NET [EN] by luisabreu on Tue, Jun 9 2009
    Filed under: Filed under: ,
  • Multithreading: APM and options for waiting until work completes

    In the last post, we’ve started looking at oldest asynchronous pattern of the .NET framework: the APM model. Today, we’re going to list the available options for waiting to the completion of an asynchronous operation started through a framework that implements APM pattern. After kicking off an asynchronous...
    Posted to LA.NET [EN] by luisabreu on Mon, Jun 8 2009
    Filed under: Filed under: ,
  • Multithreading: the IAsyncResult interface

    In the last post , we’ve started looking at the APM model used by the .NET framework. Today we’re going to talk about the role played by the IAsyncResult interface. Currently, the IAsyncResult interface has the following members: public interface IAsyncResult {     object AsyncState {...
    Posted to LA.NET [EN] by luisabreu on Mon, Jun 8 2009
    Filed under: Filed under: ,
  • Multithreading: introducing the asynchronous programming model

    Today we’re going to keep looking at multithreading on the .NET framework and we’re going to start talking about the oldest async model you’ll find in the .NET framework: the APM (asynchronous programming model). You might be asking why you need an asynchronous programming model and why shouldn’t you...
    Posted to LA.NET [EN] by luisabreu on Sun, Jun 7 2009
    Filed under: Filed under: ,
  • Multithreading: I/O and the thread pool

    When we started looking at how we could use the thread pool for asynchronous work, I (only!) mentioned three options: use the pool to run a task when IO completes; run a (possible recurrent) task at a specific time; execute a task when a kernel object is signaled. There is still another option: you can...
    Posted to LA.NET [EN] by luisabreu on Thu, Jun 4 2009
    Filed under: Filed under: ,
  • Multithreading: coding the register wait pattern

    Yesterday we’ve looked at the theory behind registered waits (btw, there were some errors on that post, but I think I’ve corrected them now). Today, we’re going to look at some code. Let’s see what happens when we use a ManualResetEvent for waiting on: class DumbHandle : WaitHandle { } static void Main...
    Posted to LA.NET [EN] by luisabreu on Wed, Jun 3 2009
    Filed under: Filed under: ,
  • Multithreading: registered waits

    In this post, we’re going to keep looking on how we can reuse the thread pool’s threads for executing specific tasks. This post is all about registered waits. A registered wait allows us to specify a callback that will be invoked when a predefined kernel object is signaled. In .NET, we register a wait...
    Posted to LA.NET [EN] by luisabreu on Tue, Jun 2 2009
    Filed under: Filed under: ,
  • Multithreading: running tasks at a specific time

    As we’ve seen , we can also use the thread pool for executing a (possible recurring) task at a specific time. To do that, we need to take a look at the Timer class. Initializing a timer is done through one of its constructors: public Timer(TimerCallback callback); public Timer(TimerCallback callback...
    Posted to LA.NET [EN] by luisabreu on Mon, Jun 1 2009
    Filed under: Filed under: ,
  • Multithreading: waiting for several work items

    In the last post , we’ve seen how we could use the thread pool for queuing work items that will be executed in one of the existing threads maintained on the default thread pool. As we’ve seen, there’s no way to say “wait for the executing actions” without using one of the synchronization kernel objects...
    Posted to LA.NET [EN] by luisabreu on Mon, Jun 1 2009
    Filed under: Filed under: ,
  • Multithreading: queuing work items

    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...
    Posted to LA.NET [EN] by luisabreu on Thu, May 28 2009
    Filed under: Filed under: ,
  • Multithreading: introducing the thread pool

    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...
    Posted to LA.NET [EN] by luisabreu on Wed, May 27 2009
    Filed under: Filed under: ,
  • Using condition variables

    A few posts ago , we’ve seen how we could create a producer/consumer stack. Let’s update the example for using condition variables. Here’s the code: class ConcurrentStack<T> {     private readonly Object _locker = new Object();     private readonly Stack<T> _stack...
    Posted to LA.NET [EN] by luisabreu on Wed, May 27 2009
    Filed under: Filed under: ,
  • 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...
    Posted to LA.NET [EN] by luisabreu on Wed, May 27 2009
    Filed under: Filed under: ,
  • Multithreading: reader/writer locks

    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...
    Posted to LA.NET [EN] by luisabreu on Tue, May 26 2009
    Filed under: Filed under: ,
Page 2 of 3 (52 items) < Previous 1 2 3 Next >