0
Invoke를 사용하고 사용하지 않는 것과 혼동합니다. 다음 예에서Invoke를 사용하는 것과 사용하지 않는 것의 차이점은 무엇입니까?
, 나는
int answer = b(10, 10);
및
int answer = b.Invoke(10, 10);
와 차이가 너무 사람이 나를 도울 수있는 참조? !
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace TEST
{
public delegate int BinaryOp(int x, int y);
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Main innvoked on thread {0}.", Thread.CurrentThread.ManagedThreadId);
BinaryOp b = new BinaryOp(add);
//int answer = b(10, 10);
int answer = b.Invoke(10, 10);
Console.WriteLine("Doing more work in Main");
Console.WriteLine("10 + 10 is {0}", answer);
Console.Read();
}
static int add(int x, int y)
{
Console.WriteLine("add innvoked on thread {0}.", Thread.CurrentThread.ManagedThreadId);
return x + y;
}
}
}
이 게시물을 참조 :의 –
K0D3R
가능한 복제 [Func을 .Invoke 대 Func을 ()() (https : //로 유래. co.kr/questions/16309286/funct-vs-funct-invoke) –
Backs