First of all, let me explain the situation ...
I have a class that has 2 properties: DataA and DataB; no matter what it is, what matters is that each can be calculated from the other. I work in a multi-threaded environment and want DataA / DataB to be calculated when and if necessary (this is not always the case both will be available). My first thought was something like ...
public SomeDataObject DataA
{
get
{
if (dataAisAvailable)
{
return dataA;
}
else
{
if (dataBisAvailable)
{
lock (dataACalcLock)
{
if (dataAisAvailable)
{
return dataA;
}
dataAisAvailable = true;
return dataA;
}
}
else
{
return null;
}
}
}
}
, , DataB , , ( thread1), dataA, ... , dataA, , ... imho. , , thread1 A, , .
, ManualResetEvents, , , .
, , , . ...
: , .NET 4.0. Silverlight...