threading problem

  • Thread starter Thread starter cody
  • Start date Start date
C

cody

When I move the slider and the ValuesChanged event is triggered, the method
seems to wait nutil the tread has finished UpdateImage() But why? It is a
separate thread why can't I move the slider until the UpdateImage method
finishes?

here is my code:

thread = new Thread(new ThreadStart(Runner));
thread.Priority = ThreadPriority.Lowest;
thread.Start();


void OnValuesChanged()
{
lock (this)
{
Monitor.Pulse(this);
}
}

void Runner()
{
lock (this)
{
while (true)
{
this.UpdateImage();
Monitor.Wait(this);
}
}
}

void UpdateImage()
{
this.img.ApplyColorMatrix(matrix, this.canvas.DisplayRectangle);
this.wndCanvas.Refresh();
}
 
Back
Top