Usually, redrawing a graph four times per second is smooth enough.
Therefore create your own control. Derive it from
Control[
^]. Override its
OnPaint()[
^] method to draw everything you need It's just some
DrawLine()[
^]s and a lot of simple geometry to compute what belongs where.
Create a bunch of member variables sufficing to describe what to draw at any given time. You won't know when exactly a redraw happens to your control.
OnPaint() uses these variables,
port_DataReceived() updates them (maybe not directly, but through calling
DataHandling() or whatever).
Put a
System.Windows.Forms.Timer[
^] in your class. There are more flavours of timers in .NET, but this one is made for UI purposes (it occasionally drops one
Tick[
^] event or the other if UI is busy anyway). Set the timer to fire four times a second. In the tick event, simply call
this.Invalidate()[
^]. It will tell the application that your control needs to be redrawn. There's no way to tell when it actually will be redrawn until OnPaint() runs.
You can further tweak that by by using a member variable
bool _hasChanged
that you set everytime new values have been received, reset after every redraw and check in the
Tick event handler to check if redrawing is actually necessary. So you might save some unnecessary drawing.
With this timer stuff, you could as well keep using ZedGraph since the redraw frequency will be significantly lowered.