jeudi 17 décembre 2015

Atomically reading values of fields via reflection

Let's suppose I have the following C# declaration:

struct Counters
{
    long a;
    long b;
    long c;
}

Is this possible to iterate through the fields of Counters and read their values using Interlocked.Read()? I.e.

foreach (var counter in typeof(Counters).GetFields())
{
    var value = Interlocked.Read(???);
}





Aucun commentaire:

Enregistrer un commentaire