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

Unable to resolve <website url> Try checking the for validity Google Pagespeed Insights

Unable to resolve <website url> Try checking the for validity Google Pagespeed Insights   You have a website and want to test it'...

Ads Inside Post

Powered by Blogger.

Arsip