private void ReadFromList()
{
lock (this) // Enter synchronization block
{
if (!readerFlag)
{ // Wait until WriteToList is done producing
try
{
// Waits for the Monitor.Pulse in WriteToList
Monitor.Wait(this);
}
catch (SynchronizationLockException e)
{
Console.WriteLine(e);
}
catch (ThreadInterruptedException e)
{
Console.WriteLine(e);
}
}
Console.WriteLine("Element removed from list invoked By Plot Team");
p1 = list[0];
list.RemoveAt(0);
readerFlag = false; // Reset the state flag to say reading
// is done.
Monitor.Pulse(this); // Pulse tells WriteToList that
// ReadFromList is done.
display(); //unit test for receiver
parsePaint();
//call the various subroutines for parsing and other function in paint module
} // Exit synchronization block
}