سلام بر تمامی برنامه نویسان عزیز 😉 در این مطلب از وب سایت پروگرم 98 کد ارتباط Data (داده) به Thread در c#.net را آماده کردم. انشاالله که این آموزش برای شما مفید باشد.
کد ارتباط Data (داده) به Thread در c#.net :
using System;
using System.Threading;
class Sum {
public Sum(int op1, int op2) {
Console.WriteLine("[Sum.Sum] Instantiated with values of {0} and {1}", op1, op2);
this.op1 = op1;
this.op2 = op2;
}
int op1;
int op2;
int result;
public int Result{ get { return result; } }
public void Add()
{
Thread.Sleep(5000);
result = op1 + op2;
}
}
class ThreadData {
static void Main() {
Sum sum = new Sum(6, 42);
using System.Threading;
class Sum {
public Sum(int op1, int op2) {
Console.WriteLine("[Sum.Sum] Instantiated with values of {0} and {1}", op1, op2);
this.op1 = op1;
this.op2 = op2;
}
int op1;
int op2;
int result;
public int Result{ get { return result; } }
public void Add()
{
Thread.Sleep(5000);
result = op1 + op2;
}
}
class ThreadData {
static void Main() {
Sum sum = new Sum(6, 42);