Calling delegates individually?

前端 未结 4 1530
逝去的感伤
逝去的感伤 2021-02-15 02:56

if I have a delegate like so:

 Delegate void Render();
 Render ToRender;

And use it here:

 ToRender += FunctionRender;
 ToRende         


        
4条回答
  •  死守一世寂寞
    2021-02-15 03:18

    foreach (Render render in ToRender.GetInvocationList())
    

    Ideal Way:

    Render temp = ToRender;
    
    if (temp != null)
    {
        foreach (Render render in temp.GetInvocationList())
        {
            BeginRender();
    
            render();
    
            EndRender();
        }
    }
    

提交回复
热议问题