Sommaire

La classe Interlocked

1. Introduction

L’espace de noms System.Threading fournit une classe statique Interlocked particulièrement utile pour la gestion de la synchronisation des ressources entre divers threads.

Voici sa définition :

public static class Interlocked  
{  
   [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]  
   [TargetedPatchingOptOut("Performance critical to inline across  
NGen image boundaries")]  
   public static long Add(ref long location1, long value);  
  
   [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]  
   [TargetedPatchingOptOut("Performance critical to inline across  
NGen image boundaries")]  
   public static int Add(ref int location1, int value);  
  
   [ComVisible(false)]  
   [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]  
   [SecuritySafeCritical]  
   public static T CompareExchange<T>(ref T location1, T value,  
T comparand) where T : class;  
  
   [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]  
   [SecuritySafeCritical]   
   public static object CompareExchange(ref object location1,  
object value, object comparand);  
  
   [SecuritySafeCritical]  
   public static double CompareExchange(ref double location1,  
double value, double comparand);  
  
   [SecuritySafeCritical]  
   public static float ...