Hi
I m adding custom control to my flowlayoutpanel , its a sort of forex data , refresh every second ,
so on each timer tick , i m adding a control , changing controls button text , then adding it to flowlayout panel ,
i m doing it at each 100ms timer tick ,
it takeing tooo much CPU ,
here is my custom Control .
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void UserControl1_Load(object sender, EventArgs e)
{
}
public void displaydata(string name , string back3price , string back3 , string back2price , string back2 , string back1price , string back1 , string lay3price , string lay3 , string lay2price , string lay2 , string lay1price , string lay1 )
{
lblrunnerName.Text = name.ToString();
btnback3.Text = back3.ToString() + "\n" + back3price.ToString();
btnback2.Text = back2.ToString() + "\n" + back2price.ToString();
btnback1.Text = back1.ToString() + "\n" + back1price.ToString();
btnlay1.Text = lay1.ToString() + "\n" + lay1price.ToString();
btnlay2.Text = lay2.ToString() + "\n" + lay2price.ToString();
btnlay3.Text = lay3.ToString() + "\n" + lay3price.ToString();
}
and here is how i m adding control;
private void timer1_Tick(object sender, EventArgs e)
{
localhost.marketData[] md;
md = ser.getM1();
flowLayoutPanel1.Controls.Clear();
foreach (localhost.marketData item in md)
{
UserControl1 ur = new UserControl1();
ur.Name = item.runnerName + item.runnerID;
ur.displaydata(item.runnerName, item.back3price, item.back3, item.back2price, item.back2, item.back1price, item.back1, item.lay3price, item.lay3, item.lay2price, item.lay2, item.lay1price, item.lay1);
flowLayoutPanel1.SuspendLayout();
flowLayoutPanel1.Controls.Add(ur);
flowLayoutPanel1.ResumeLayout();
}
}
now its happing on 10 times on each send , taking 60% of my Core2Duo cpu .
is there any other way , i can just add contols first time , and then change the text of cutom controls buttons on runtime on each refresh or timer tick
i m using c# .Net