Asynchronous Delegates Vs Thread/ThreadPool?

前端 未结 8 2136
醉梦人生
醉梦人生 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:33

    Asynchronous delegates are executed using a thread from the thread pool. This reduces the overhead of manually creating a thread and disposing it. Threadpool threads have lesser overhead than the ones that you create manually and has to be disposed.

    Also, executing a method in a manually created thread gives you more control such as the ability to interrupt the thread, abort it, check its state, set its priority etc.

    Async delegates are used if you want to quickly make a method execute asynchronously.

    Also, EndInvoke allows you the return an object out which allows you to retrieve the results of the execution. A Thread.Join, although functionally equivalent, does not allow you to return anything.

提交回复
热议问题