Profile Picture

UI can't display properly after running for a while(Aligning Chart Areas Chart)

Posted By Violet Han 15 Years Ago

UI can't display properly after running for a while(Aligning Chart...

Author
Message
Violet Han
questionmark Posted 15 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: Forum Members
Last Active: 15 Years Ago
Posts: 1, Visits: 1

HI Neveron Team,

I made a little change to Aligning Chart Areas(All Examples -> Layout -> Aligning Chart Areas) to make it refresh its data constantly.

The changed code is as below:

private void NewDataBtn_Click(object sender, System.EventArgs e)
  {
            if (timer != null)
                timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
            timer = new System.Threading.Timer(new System.Threading.TimerCallback(RefreshData), null, 0, 100);
           
   
  }
        private void RefreshData(object sender)
        {
            GenerateOHLCData(m_Stock, prevCloseValue, dataPointCount);
   GenerateVolumeData(m_Volume, prevVolumeValue, dataPointCount);

   m_Line.Values = m_Function.Calculate();
            nChartControl1.Refresh();
        }

After running for a while, I found the UI counn't display properly(as UI1.JPG).

can you tell me why this happens and how to prevent it?

Thank you very much.



Attachments
UI1.JPG (43 views, 71.00 KB)
Milen Metodiev
Posted 15 Years Ago
View Quick Profile
Forum Member

Forum Member (48 reputation)Forum Member (48 reputation)Forum Member (48 reputation)Forum Member (48 reputation)Forum Member (48 reputation)Forum Member (48 reputation)Forum Member (48 reputation)Forum Member (48 reputation)Forum Member (48 reputation)

Group: Nevron Team
Last Active: 14 Years Ago
Posts: 48, Visits: 1
 Hi Violet,

In general it is not allowed to call methods of the control in the context of a different thread. The System.Threading.Timer executes the callback method on a threadpool thread, so you have to use the Invoke method. Please refer to the following MSDN topic for more information:

http://msdn.microsoft.com/en-us/library/ms171728.aspx

Alternatively, you can use a System.Windows.Forms.Timer, like in the following examples in our Winforms demo application:

    All Examples > Chart Gallery > Grid Surface > Waves

    All Examples > Chart Gallery > Area > Real Time Area

I hope this helps.

Best Regards,
Milen Metodiev





Similar Topics


Reading This Topic