Hi folks,
i've got the following code :-
while (....)
{
var foo = DoTheFooShakeShakeShake(..);
foos.Add(foo); // foos is an IList<Foo>, btw and is new'd, above.
if (foos.Count % 100 == 0)
{
var e = new CustomFooEventArgs { UserId = whatever, Foos = foos };
OnFooPewPew(this, e);
foos.Clear();
}
}
// We still might have some foo's left over.. so send em off also.
// Excuse the woeful var names, below.
var e2 = new CustomFooEventArgs { UserId = whatever, Foos = foos };
OnFooPewPew(this, e2);
So, i grab all the foo's for some while/loop condition. Every 100 foo's i then fire an event, which passes the list of foo's off to the subscriber. I then clear this list of foos. Once the loop is finished, i then fire off any remaining foo's to the subscriber.
So - if i fire off an event, which contains the list of foo's ... and then i CLEAR that list .. will that mean that the subscriber can possibly get that list, which is now empty? Should I be passing across a COPY of the list ... and then clearing the original list?