private void ShowContentThreadSafe(int level)
{
if (UcView.TreeList.InvokeRequired)
{
UcView.TreeList?.Invoke(new Action1<int>(a => ShowContent(level)));
}
else
ShowContent(level);
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class ActionDemo : MonoBehaviour {
void Start(){
Action<string> SampleAction; //action dont need an explicit delegate to be declared (Action is special kind of delegate which takes parameters but returns nothing)
SampleAction = PrintMsg;
SampleAction += delegate(string s) {Debug.Log("from anonymous method : "+s);} ; //using anonymous method
SampleAction += s => Debug.Log("using lambda expression : "+s); //using lambda expression
SampleAction ("Hello shrinath");
}
void PrintMsg(string msg1){
Debug.Log ("msg : " + msg1);
}
}
//one of three built-in generic delegate types:
static void ConsolePrint(int i)
{
Console.WriteLine(i);
}
static void Main(string[] args)
{
Action<int> printActionDel = ConsolePrint;
printActionDel(10);
}