this code is executed in a separate thread that creates a statistic by running the same simulation several times while slightly altering a value each time:
Monitor.Enter(TrajectoryBitmap);
for (int y = 0; y < TrajectoryBitmapHeight - 1; y++)
TrajectoryBitmap.SetPixel(0, y, Color.Black);
for (int x = 1; x < TrajectoryBitmapWidth; x++)
{
TrajectoryBitmap.SetPixel(x, TrajectoryBitmapHeight - 1, Color.Black);
for (int y = 0; y < TrajectoryBitmapHeight - 1; y++)
TrajectoryBitmap.SetPixel(x, y, Color.White);
}
Monitor.Exit(TrajectoryBitmap);
Why does this return an InvalidOperationException (object already used elsewhere)? Shouldn't the Monitor prevent that, or am I using it wrong?
On an unrelated note, why do I have to use Invoke() and delegates to get the SelectedIndex of a ComboBox in another thread, but can access the Text of a TextBox without one?
Help with the problem and/or an answer for the question would be much appreciated.


Sign In
Create Account


Back to top









