I'm pretty new to C# programming, and the concept of the GC, and its realtions to IDisposable is still a bit vague. What does calling Dispose mean in terms of the garbage collection? Specifically i wonder if the following code may fail occationally, depending on when the garbage collection kicks in. (I have not been able to make it crash during my tests).
//List<TestClass2> tc2List;
//TestClass2 invokes a thread. It implements IDisposable.
//Its Dispose() sets a stop-condition for the thread,
//and joins the thread, awaiting it to stop. (may take 100 msek)
tc2List.RemoveAll(t =>
{
if (String.Compare(t.Name, "Orange") == 0)
{
t.Dispose(); //May take up to 100 msek
return true;
}
return false;
});