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 819583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:20:00+00:00 2026-05-15T02:20:00+00:00

I m adding custom control to my flowlayoutpanel , its a sort of forex

  • 0

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 taking too much CPU ,

here is my custom Control .

public partial class UserControl1 : UserControl
{
    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 .
i want to refresh it fast , i need some optimization tips

is there any other way , i can just add controls first time , and then change the text of custom controls buttons on runtime on each refresh or timer tick

i m using c# .Net

  • 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-15T02:20:01+00:00Added an answer on May 15, 2026 at 2:20 am

    it’s happening 10 times a second because you’re telling it to.

    there’s 1000ms in a second

    if you’re doing it every 100ms, then you’re performing the action 10 times a second.


    Okay, there’s a few things going on here. First, you’ll need to maintain a handler or a NAME for the various controls that are to be updated. This can be done either via an defined object, or using the FINDCONTROL(“ControlName”).

    Now, for your issue with the accessing the control in the timer control, that’s due to THREADS! The code inside the Timer_Elapsed event happens on a sepeaate thread, thus, to impact the UI you need to make your code thread safe.

    Consider these objects:

    // The declaration of the textbox.
    private TextBox m_TextBox;
    public delegate void UpdateTextCallback(string text);
    

    Then you’d have a method that performs the actual change

    // Updates the textbox text.
    private void UpdateText(string text)
    {
      // Set the textbox text.
      m_TextBox.Text = text;
    }
    

    And then in your separate thread, call this via

    m_TextBox.Invoke(new UpdateTextCallback(this.UpdateText),  new object[]{”Text generated on non-UI thread.”});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am adding custom controls to a FlowLayoutPanel. Each control has a date property.
I'm dynamically adding a custom user control to the page as per this post
I'm creating a lot of custom controls and adding them to a FlowLayoutPanel. There
ActionScript 3 / Flex 3 - Adding custom events to a class Say I
I'm in the process of adding custom buttons to my iPhone UI and want
I am adding a custom background for my UINavigationBar. It works fine as long
I am adding a custom background image to my navigation bar by creating an
I'm using a TableAdapter for the first time and adding a custom query to
I have a JUnit test that tests adding Strings to a Dictionary custom type.
I've made it a personal rule to inherit every UI control before using it.

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.