2 using System
.Collections
.Generic
;
4 namespace LanSpider
.Multithreading
7 /// Consumes work items produced by WorkManager.
9 public class Consumer
< TResult
>
11 private List
<TResult
> _results
;
12 private readonly object _resultsLock
= new object();
14 public IEnumerable
<TResult
> Results
18 if ( _results
== null )
20 throw new InvalidOperationException( "Cannot return results before work was preformed" );
27 public void Consume( TResult result
)
31 if ( _results
== null )
33 _results
= new List
<TResult
>();
36 _results
.Add( result
);