Asynchronous Delegates Vs Thread/ThreadPool?

前端 未结 8 2191
醉梦人生
醉梦人生 2020-12-22 23:57

I need to execute 3 parallel tasks and after completion of each task they should call the same function which prints out the results.

I don\'t understand in .net why

8条回答
  •  不知归路
    2020-12-23 00:30

    Delegate.BeginInvoke grabs a threadpool thread and executes the passed delegate on that thread. So when you use BeginInvoke the .NET Framework does a lot of work like creating new thread, starting it etc.

    You can also take a look at ThreadPool.QueueUserWorkItem(delegate { /* do stuff */ }); for an alternative approach to async calls.

提交回复
热议问题