I am looking for a class that defines the holding structure for an object. The value for this object can be set later than when creating this container. It is useful to pass such a structure to lambdas or in callback functions, etc.
Say:
class HoldObject<T> {
public T Value { get; set; }
public bool IsValueSet();
public void WaitUntilHasValue();
}
HoldObject<byte[]> downloadedBytes = new HoldObject<byte[]>();
DownloadBytes("http://www.stackoverflow.com", sender => downloadedBytes.Value = sender.GetBytes());
Defining this structure is pretty easy, but I'm trying to figure out if it is available in FCL. I also want this to be an efficient structure that has all the necessary functions, such as thread safety, efficient wait, etc.
Any help is greatly appreciated.
source
share