public void NoStateAndNoLambda()
 {
     _globalSum = 0;
     for (int i = 0; i < Elements; ++i)
     {
         TaskStub.StartNew(AddFunction);
     }
 }
 public void NoCapturedState()
 {
     _globalSum = 0;
     for (int i = 0; i < Elements; ++i)
     {
         TaskStub.StartNew(() => { _globalSum += Data.Default.Value; });
     }
 }
 public void PassStateAsParameter()
 {
     _globalSum = 0;
     for (int i = 0; i < Elements; ++i)
     {
         var data = new Data {
             Value = i
         };
         TaskStub.StartNew(d => { _globalSum += (d as Data).Value; }, data);
     }
 }
 public void CaptureState()
 {
     _globalSum = 0;
     for (int i = 0; i < Elements; ++i)
     {
         var data = new Data {
             Value = i
         };
         TaskStub.StartNew(() => { _globalSum += data.Value; });
     }
 }