My objects are fighting over the Graphics object - Help
Greetings (New to this forum).
I program in C#.
I created a winform wich paints a man. The man can be moved by the arrow keys (Key Press event).
I tried to add a moving ball. the ball movment is done in a different tread. But both treads use the same Graphics object to paint the man and to paint the ball on the winform.
It works, but now and then I get an exception says both treads try to use the Graphics object simultaniusly.
What is the right way to do it?
My plans are to write a simple arcade game. One hero controlled by the keys and 1-2 enemies (on diffrerent treads).