Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6560751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:30:06+00:00 2026-05-25T13:30:06+00:00

I have a C# Chart Control and I data bind it like so. chart.Series[0].Points.DataBindXY(xAxis,

  • 0

I have a C# Chart Control and I data bind it like so.

chart.Series[0].Points.DataBindXY(xAxis, yAxis);
where xAxis is List<String> and yAxis is List<Double>

On another thread xAxis, and yAxis are constantly updated (Multiple calls to .Add())

However the chart does not update unless I call DataBindXY() again, however this seems to cause issue because every once and a while i get

 Error: "Collection was modified; enumeration operation may not execute." 

Which at some point causes my program to crash with

 Error: "system.reflection.targetinvocationexception' occurred in mscorlib.dll"

-Is there something im missing as far as updating? or should I be doing this diffrently, let me know if you need more information.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:30:07+00:00Added an answer on May 25, 2026 at 1:30 pm

    You need to add locking or synchronization both in your update method and your DataBindXY method. You cannot modify a List and read it at the same time, because operations on Lists are not thread safe.

    I’d recommend reading this (or one of the many, many other) introductions on thread synchronization in C#: http://msdn.microsoft.com/en-us/library/ms173179.aspx

    EDIT: Here is an example of how to do this:

    Object lockOnMe = new Object();
    
    ... in your Add loop
    
    (int i = 0; i < dacPoints.Count; i += 1) { 
        TimeSpan span = new TimeSpan(0, 0, i + 1); 
        lock (lockOnMe) { 
            presenter.addPoint(span.ToString(), dacPoints[i]); 
        } 
        System.Threading.Thread.Sleep(200); 
    }
    
    ... when calling DataBindXY()
    
    lock (lockOnMe) {
        // Note that I copy the lists here.  
        // This is because calling DataBindXY is not necessarily a serial, 
        // blocking operation, and you don't want the UI thread touching 
        // these lists later on after we exit the lock
        chart.Series[0].Points.DataBindXY(xAxis.ToList(), yAxis.ToList());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a chart in a Report Viewer control: Series data is a sum:
I have a pie chart in BIRT and about 80 data points. I'm looking
I'm using Microsoft's Chart control to plot some series, but if I have no
I have a pie chart on a WPF user control whose data changes periodically,
I would like to create a new dynamic chart control. This chart will have
In the MS Chart control (which they bought from Dundas), I have three series
I have a chart control in XAML, and datapoints that are bind to the
i have an ms chart control. i would like to be able to scale
I have installed the new asp:chart control on my machine and have built an
I am using the new ASP control Chart, but I have some problems with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.