Parent task does not wait for child task to complete

前端 未结 3 1968
北海茫月
北海茫月 2021-01-12 08:28

So here is my code

Task parent = Task.Run(() =>
{
    var result = new int[3];

    TaskFactory tf = new TaskFactory(TaskCreationOptions.Atta         


        
3条回答
  •  [愿得一人]
    2021-01-12 09:01

    In Task.Run's documentation, you'll find that it specifies

    Its CreationOptions property value is TaskCreationOptions.DenyChildAttach.

    So, even though you specify TaskCreationOptions.AttachedToParent, it is ignored.

提交回复
热议问题