Ridwan Sameer asked:
But the drawing of the car object will be separate from passing the object yes? (I.E even though I pass the object from one thread to another, does not mean the object would be drawn at the appropriate panel)
This is yet another chapter you need to learn. It depends on what do you mean by "drawing". If you mean graphics rendering (
Graphics graphics = /*...*/; graphics.Draw…
), it's independent from everything. Basically, there are thee different activities. 1) Non-UI thread: logic, scenario of motion, calculation,
Invalidate
(see below), pushing notification to the UI thread (
Invoke
); 2) UI-thread: handling notification, execution of delegate instance send via
Invoke
; only this part uses some properties of UI objects; 3) rendering, which also executed in the UI thread, but in the handler of the event
Control.Paint
(or overridden method
Control.OnPaint
).
For further detail, please see my past answers:
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[
^],
How to speed up my vb.net application?[
^],
capture the drawing on a panel[
^],
Drawing Lines between mdi child forms[
^].
You really need to understand the concept and how it all works.
—SA