cpu load when setting textbox value

62 views Asked by At

I have a simple program that sniff ip packets.

in this porgram I have a textbox that show received values. receiving values are so fast and lots of numbers.(small but huge number in small time)

this happens by this code: (note: I've used append text before and listbox instead of textbox but high cpu usage happend)

delegate void SetTextCallback(string text);
private void SetText(string text)
        {            
            if (txtInfo.InvokeRequired)
            {
                SetTextCallback d = new SetTextCallback(SetText);                
                this.BeginInvoke(d, new object[] { text });
            }
            else
            {               
                txtInfo.Text+=text;

            }
        }

when receiving new value set text by this code:

SetText(MakeIPTreeNode(ipHeader)); //MakeIPTreeNode(ipHeader) : is some string value

is there any threading approach for solving high cpu usage? I know that this problem is for bad coding architecture

thanks

0

There are 0 answers