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

Multiple attribute passing in querySelectorAll

Multiple attribute passing in querySelectorAll     Here I am demonstrating code to how to pass multiple attributes in querySelectorAll. <...

Ads Inside Post

Powered by Blogger.

Arsip