For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Saturday, February 06, 2016

update control value in C# Thread

How to update control value in C# Thread.



Use below sample of code:

Thread t1=new Thread();
String b="";
int all=0;
 private void button5_Click(object sender, EventArgs e)
 {
         
            t1 = new Thread(new ThreadStart(MyCodeRun));  t1.Start();
 }

void MyCodeRun()
{
           while (String.IsNullOrEmpty(b) || String.IsNullOrWhiteSpace(b))
            {
                this.BeginInvoke(new MethodInvoker(changeValue));
                all = all + 1;
                System.Threading.Thread.Sleep(1000);
            }
 }

 private void changeValue()
{
            label1.Text =all + "";
}
Share:

0 comments:

Post a Comment

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip