Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

How to display Values using 2 class with thread in c#

$
0
0

Hi., I should use 2 class like, ClassA and ClassB  and each class have one label to print result.

I created a variable in ClassA , and created a method like below.

Protected void Display()

{

for (Val = 1; Val <= 10; Val++)
{
lblMain.Text = "The Current Value in ClassA: " + Val;
Thread.Sleep(2000);
ClassB objClassB = new ClassB();
lblSub.Text = "The Current Value in ClassB: " + objClassB.PrintValue(Val);
}

}

 I have created a method called PrintValue() in ClassB

 
public string PrintValue(int pVal)
{
return pVal.ToString();
}

Finally It displays last value of for loop outcome value.

But i should display the Value like, 1 in lblMain.Text after 2 seconds 1 in lblSub.Text like wise it should change the value and print.

We should view the changing value using thread.

How to do that in c#?



Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>