Typesafe fire-and-forget asynchronous delegate invocation in C#

后端 未结 7 1793
陌清茗
陌清茗 2020-12-28 19:41

I recently found myself needing a typesafe \"fire-and-forget\" mechanism for running code asynchronously.

Ideally, what I would want to do is somet

7条回答
  •  醉梦人生
    2020-12-28 20:01

    You can pass EndInvoke as AsyncCallback for BeginInvoke:

    Action action = // ...
    
    action.BeginInvoke(buffer, 0, buffer.Length, action.EndInvoke, null);
    

    Does that help?

提交回复
热议问题