You did not show your code. Probably the solution is simple: you need to enable
DoubleBuffering
for the form where you render your graphics. If this is a control other than form, you will need to use
Control.SetStyle
and add the following
System.Windows.Forms.ControlStylesBits
:
System.Windows.Forms.ControlStylesBits.OptimizedDoubleBuffer | System.Windows.Forms.ControlStylesBits.AllPaintingInWmPaint
; as this method is protected, you can do this only in a class derived from
Control
.
Now, for transition you should better use a separate thread (
BackgroundWorker
will do well) with
System.Threading.Thread.Sleep
call in the cycle, to get some delay. As transitions go, every time you need to re-render the picture, call
Control.Invalidate
, optionally with a parameter (
Rectangle
or
Region
) to optimize it by re-rendering only the part of the scene.
You cannot call anything related to UI from non-UI thread. Instead, you need to use the method
Invoke
or
BeginInvoke
of
System.Windows.Threading.Dispatcher
(for both Forms or WPF) or
System.Windows.Forms.Control
(Forms only).
You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke()[
^],
Problem with Treeview Scanner And MD5[
^].
See also more references on threading:
How to get a keydown event to operate on a different thread in vb.net[
^],
Control events not firing after enable disable + multithreading[
^].
—SA