Click here to Skip to main content
14,603,017 members

WPF Real-time Monitor Control (Rolling Monitor)

Rate this:
4.32 (9 votes)
Please Sign up or sign in to vote.
4.32 (9 votes)
25 Apr 2008CPOL
An article introducing the WPF Realtime Monitor Control, for creating a real-time view of continuous data

Code version

Image 1

^^^ Monitor Demo


^^^ Rolling Monitor as used in CIRIP (A Computationally Intelligent Railway Intervention Planner) for monitoring connection count and thread count.


This article presents the WPF Rolling Monitor aka Realtime Monitor Control. It is used to present real-time continuous data in a simple to use control with automatic updates. The monitor displays data in a similar manor to that of the Microsoft Windows Task Manager > Performance CPU Usage History view.

Using the Code

The monitor is built around two classes, RollingSeries and RollingMonitor. RollingMonitor is the control added to the interface, while RollingSeries represents a continous stream of data.


The constructor accepts a reference to an instantiated RollingMonitor and a NextValueDelegate. The NextValueDelegate...

public delegate double NextValueDelegate();

... returns the current value of continues trend of data (e.g. current CPU usage).

RollingSeries has the following accessor properties;

  • IsRunning - Pauses the thread reading from the NextValueDelegate. Note that pausing a RollingSeries does not automatically pause all other RollingSeries associated with a specific RollingMonitor.
  • LineBrush - The Brush used for rendering the data on the monitor.
  • LineThickness - The thickness of the rendered line on the monitor.


As previously stated, the RollingMonitor class is the UIElement added to the user interface which displays the data of the RollingSeries. It has a number of properties for customising the look and feel of the displayed output;

  • MaxValue - The maximum value the monitor is capable of displaying; any value greater than this will be rendered at the max value level (see demo example).
  • MinValue - The minimum value the monitor is capable of displaying; any value lower than this will be rendered at the min value level.
  • MaintainHistoryCount* - The number of previous history data to maintain; higher values result in higher computational complexity of rendering and greater memory usage, however too low a value and the whole monitor will not be filled.
  • UpdateInterval - The amount of time (in milliseconds) before the next data is retrieved; a higher value slows the speed of the monitor down and hence the MaintainHistoryCount may be lowered resulting in lower computational complexity. Lower values of UpdateInterval results in jerkier looking animation.
  • MinValueSpacing - Used to set the minimum with between UpdateInterval spacing so that data does not become mashed when the control is resized relatively narrow.

*Note in version the parameter of RollingMonitor must be set prior to creating RollingSeries; this will be improved upon in later versions.

Example Code


<Window x:Class="WPFRollingMonitorDemonstration.Window1"
    Title="Rolling Monitor Demonstration" Height="100" Width="300">
    <rolling:RollingMonitor Name="monitor" Margin="5"/>


namespace WPFRollingMonitorDemonstration
    public partial class Window1 : Window
        private Random random = new Random();

        public Window1()

            RollingSeries s1 = new RollingSeries(monitor, new RollingSeries.NextValueDelegate(NextValue));
            RollingSeries s2 = new RollingSeries(monitor, new RollingSeries.NextValueDelegate(NextValue));
            s2.LineBrush = new SolidColorBrush(Color.FromRgb(255, 0, 0));
            s2.LineThickness = 0.25;
            RollingSeries s3 = new RollingSeries(monitor, new RollingSeries.NextValueDelegate(NextValue));
            s3.LineBrush = new SolidColorBrush(Color.FromRgb(0, 255, 0));
            s3.LineThickness = 0.25;

            monitor.MaxValue = 25;

        private double NextValue()
            return random.Next(0, 100);

Three instances of RollingSeries are created, all initialised with the same RollingMonitor and a delegate returning a random number between 0 and 100. Note however that the maximum value for the rolling monitor is set to 25, so any value above 25 appears as a value of 25 (see above).


  • Allow modification of RollingMonitor parameters after RollingSeries have been added.
  • Monitor data series customisation via user interface.
  • Performance optimisation.
  • Automatic scaling.
  • Axis labels.


Version - Initial build

Additional Licensing Notes

Please feel free to use this in your work, however please be aware that a modified The Code Project Open License (CPOL) is in use; basically it is the same as the standard license except that this code must not be used for commercial or not-for-profit commercial use without prior authorisation. Please see license.txt or license.pdf in the included source and demo files.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Derek Bartram
Software Developer Rail Research UK
United Kingdom United Kingdom
I originally studied for a masters in engineering of software engineering at The University of Birmingham during 2000-2004, of which I received a 2:1. I continued at Birmingham University working with Civil Engineering and Rail Research UK where I am currently in my final year of a 3 year PhD project developing a Computational Intelligent Approach to Railway Intervention Planning. Although my work has a significant focus on railway engineering and associated practices much of my work is with data mining (on SQL Server 2008) and computational intelligence (CI) techniques. My key areas of expertise in CI are clustering algorithms (including Rival Penalised Competitive Learning) and evolutionary algorithms.

Outside of my formal work I enjoy testing the latest technologies such as .NET 3.5 and the many frameworks of which it comprises (mainly WPF). I have several projects on the go including a .NET and DirectX port of Quake 3 and many utility libraries. I also maintain an extensive website coded in Cold Fusion which is regularly updated; more information is available about me there.

Comments and Discussions

QuestionRevised to Plot Sine Wave Pin
BarbPresley38-Mar-14 14:58
MemberBarbPresley38-Mar-14 14:58 
QuestionSmoother scrolling Pin
TobiasVdb24-Jan-12 23:56
MemberTobiasVdb24-Jan-12 23:56 
AnswerRe: Smoother scrolling Pin
Derek Bartram3-Apr-13 12:50
MemberDerek Bartram3-Apr-13 12:50 
Questionhow to stop the thread Pin
mickwijaya25-Jul-11 17:22
Membermickwijaya25-Jul-11 17:22 
AnswerRe: how to stop the thread Pin
Nils de Jong29-Dec-11 22:29
MemberNils de Jong29-Dec-11 22:29 
GeneralRe: how to stop the thread Pin
79850015021-Jul-12 19:35
Member79850015021-Jul-12 19:35 
Generalcool Pin
zhujinlong1984091317-Apr-09 0:03
Memberzhujinlong1984091317-Apr-09 0:03 
GeneralDisappointed with CPU performance Pin
Glynn4-Jan-09 23:35
MemberGlynn4-Jan-09 23:35 
GeneralRe: Disappointed with CPU performance Pin
Derek Bartram5-Jan-09 23:54
MemberDerek Bartram5-Jan-09 23:54 
GeneralRe: Disappointed with CPU performance Pin
andyb197929-Mar-12 3:19
Memberandyb197929-Mar-12 3:19 
GeneralFeeding data from a seperate application or serial port Pin
PeterKovach11-Nov-08 6:06
MemberPeterKovach11-Nov-08 6:06 
GeneralRe: Feeding data from a seperate application or serial port Pin
Derek Bartram11-Nov-08 6:39
MemberDerek Bartram11-Nov-08 6:39 
GeneralRe: Feeding data from a seperate application or serial port Pin
PeterKovach11-Nov-08 6:49
MemberPeterKovach11-Nov-08 6:49 
GeneralRe: Feeding data from a seperate application or serial port Pin
Derek Bartram11-Nov-08 7:02
MemberDerek Bartram11-Nov-08 7:02 
GeneralRe: Feeding data from a seperate application or serial port Pin
PeterKovach11-Nov-08 7:30
MemberPeterKovach11-Nov-08 7:30 
GeneralA good start Pin
Keith Rule25-Apr-08 12:35
professionalKeith Rule25-Apr-08 12:35 
This is a nice start on a WPF chart recorder. As you noted, you really do need to put up a Y-axis. Also, auto scaling isn't hard if you buffer your visible data.

One other thing to note is that my experience with chart recording is that you usually need to record multiple data sources at once. You've done this by overlaying different data sources. However, having a chart that allows each data source to be on independent chart lines with each having an independent axis and correlated on the X-axis would be very useful.

Again, a nice start. I look forward to you filling out the features on this.

Keith Rule

GeneralRe: A good start Pin
Derek Bartram25-Apr-08 13:21
MemberDerek Bartram25-Apr-08 13:21 
GeneralRe: A good start Pin
PeterKovach11-Nov-08 7:54
MemberPeterKovach11-Nov-08 7:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 25 Apr 2008


77 bookmarked