Invoke(Delegate)

后端 未结 9 1137
误落风尘
误落风尘 2020-11-22 16:33

Can anybody please explain this statement written on this link

Invoke(Delegate):

Executes the specified delegate on the thread that owns th

9条回答
  •  被撕碎了的回忆
    2020-11-22 16:52

    Delegate are essentially inline Action's or Func. You can declare a delegate outside the scope of a method which you are running or using a lambda expression(=>); because you run the delegate within a method, you run it on the thread which is being run for the current window/application which is the bit in bold.

    Lambda example

    int AddFiveToNumber(int number)
    {
      var d = (int i => i + 5);
      d.Invoke(number);
    }
    

提交回复
热议问题