
Untitled
By: a guest on
Jun 14th, 2012 | syntax:
None | size: 0.83 KB | hits: 18 | expires: Never
Lazy<T> breaks when exception is handled
Lazy<int> lazyCount = new Lazy<int>(() => { throw new NotImplementedException(); }, System.Threading.LazyThreadSafetyMode.None);
Func<int> valueGenerator = () => { throw new NotImplementedException(); };
try
{
int value = lazyCount.Value;
}
catch (NotImplementedException e)
{
Console.WriteLine("Breaks");
}
try
{
int value = valueGenerator();
}
catch (NotImplementedException e)
{
Console.WriteLine("Doesn't Breaks");
}
try
{
throw new NotImplementedException();
}
catch (NotImplementedException e)
{
Console.WriteLine("Doesn't break");
}
Console.ReadLine();
Func<int> a = () => { throw new NotImplementedException(); };
try
{
//int value = lazyCount.Value;
a();
}
catch (NotImplementedException e)
{
}