Will a C# console app wait for all task.runs to finish? [duplicate]










0
















This question already has an answer here:



  • Running multiple async tasks and waiting for them all to complete

    8 answers



I have a console app that runs a whole bunch of things via task.run. I need all of those things to complete before the app terminates. The main line code just runs off the end of main. Will the process shutdown wait for all my task.runs to complete or do I have to wire that up myself. If so does anybody have any suggestions.










share|improve this question















marked as duplicate by Igor c#
Users with the  c# badge can single-handedly close c# questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 12 '18 at 17:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • Since tasks will run on background threads (i am ignoring other mechanisms to achieve concurrent/async behavior here), your program/process will not wait for them to finish before terminating. Rather, when your main thread terminates (more precisely, when the last foreground thread terminates), all still running background threads (your tasks) will simply be killed off unceremoniously...

    – elgonzo
    Nov 12 '18 at 17:33
















0
















This question already has an answer here:



  • Running multiple async tasks and waiting for them all to complete

    8 answers



I have a console app that runs a whole bunch of things via task.run. I need all of those things to complete before the app terminates. The main line code just runs off the end of main. Will the process shutdown wait for all my task.runs to complete or do I have to wire that up myself. If so does anybody have any suggestions.










share|improve this question















marked as duplicate by Igor c#
Users with the  c# badge can single-handedly close c# questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 12 '18 at 17:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • Since tasks will run on background threads (i am ignoring other mechanisms to achieve concurrent/async behavior here), your program/process will not wait for them to finish before terminating. Rather, when your main thread terminates (more precisely, when the last foreground thread terminates), all still running background threads (your tasks) will simply be killed off unceremoniously...

    – elgonzo
    Nov 12 '18 at 17:33














0












0








0









This question already has an answer here:



  • Running multiple async tasks and waiting for them all to complete

    8 answers



I have a console app that runs a whole bunch of things via task.run. I need all of those things to complete before the app terminates. The main line code just runs off the end of main. Will the process shutdown wait for all my task.runs to complete or do I have to wire that up myself. If so does anybody have any suggestions.










share|improve this question

















This question already has an answer here:



  • Running multiple async tasks and waiting for them all to complete

    8 answers



I have a console app that runs a whole bunch of things via task.run. I need all of those things to complete before the app terminates. The main line code just runs off the end of main. Will the process shutdown wait for all my task.runs to complete or do I have to wire that up myself. If so does anybody have any suggestions.





This question already has an answer here:



  • Running multiple async tasks and waiting for them all to complete

    8 answers







c# asynchronous






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 20:42









marc_s

580k13011181266




580k13011181266










asked Nov 12 '18 at 17:25









pm100pm100

25.4k1658104




25.4k1658104




marked as duplicate by Igor c#
Users with the  c# badge can single-handedly close c# questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 12 '18 at 17:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Igor c#
Users with the  c# badge can single-handedly close c# questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 12 '18 at 17:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Since tasks will run on background threads (i am ignoring other mechanisms to achieve concurrent/async behavior here), your program/process will not wait for them to finish before terminating. Rather, when your main thread terminates (more precisely, when the last foreground thread terminates), all still running background threads (your tasks) will simply be killed off unceremoniously...

    – elgonzo
    Nov 12 '18 at 17:33


















  • Since tasks will run on background threads (i am ignoring other mechanisms to achieve concurrent/async behavior here), your program/process will not wait for them to finish before terminating. Rather, when your main thread terminates (more precisely, when the last foreground thread terminates), all still running background threads (your tasks) will simply be killed off unceremoniously...

    – elgonzo
    Nov 12 '18 at 17:33

















Since tasks will run on background threads (i am ignoring other mechanisms to achieve concurrent/async behavior here), your program/process will not wait for them to finish before terminating. Rather, when your main thread terminates (more precisely, when the last foreground thread terminates), all still running background threads (your tasks) will simply be killed off unceremoniously...

– elgonzo
Nov 12 '18 at 17:33






Since tasks will run on background threads (i am ignoring other mechanisms to achieve concurrent/async behavior here), your program/process will not wait for them to finish before terminating. Rather, when your main thread terminates (more precisely, when the last foreground thread terminates), all still running background threads (your tasks) will simply be killed off unceremoniously...

– elgonzo
Nov 12 '18 at 17:33













2 Answers
2






active

oldest

votes


















1














If you have an array of tasks, you can wait for all of them to complete using the



Task.WaitAll(tasks_array);





share|improve this answer
































    0














    On a console app, the process shutdown will not wait for your tasks to finish. It calls ExitProcess, which effectively terminates all threads, including the thread pool that services the Tasks.



    As @Ryan Pierce Willems wrote, you need to call Task.WaitAll to make sure you wait for all tasks to complete.






    share|improve this answer





























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      If you have an array of tasks, you can wait for all of them to complete using the



      Task.WaitAll(tasks_array);





      share|improve this answer





























        1














        If you have an array of tasks, you can wait for all of them to complete using the



        Task.WaitAll(tasks_array);





        share|improve this answer



























          1












          1








          1







          If you have an array of tasks, you can wait for all of them to complete using the



          Task.WaitAll(tasks_array);





          share|improve this answer















          If you have an array of tasks, you can wait for all of them to complete using the



          Task.WaitAll(tasks_array);






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 12 '18 at 17:32









          D-Shih

          26.3k61531




          26.3k61531










          answered Nov 12 '18 at 17:27









          Ryan Pierce WilliamsRyan Pierce Williams

          44719




          44719























              0














              On a console app, the process shutdown will not wait for your tasks to finish. It calls ExitProcess, which effectively terminates all threads, including the thread pool that services the Tasks.



              As @Ryan Pierce Willems wrote, you need to call Task.WaitAll to make sure you wait for all tasks to complete.






              share|improve this answer



























                0














                On a console app, the process shutdown will not wait for your tasks to finish. It calls ExitProcess, which effectively terminates all threads, including the thread pool that services the Tasks.



                As @Ryan Pierce Willems wrote, you need to call Task.WaitAll to make sure you wait for all tasks to complete.






                share|improve this answer

























                  0












                  0








                  0







                  On a console app, the process shutdown will not wait for your tasks to finish. It calls ExitProcess, which effectively terminates all threads, including the thread pool that services the Tasks.



                  As @Ryan Pierce Willems wrote, you need to call Task.WaitAll to make sure you wait for all tasks to complete.






                  share|improve this answer













                  On a console app, the process shutdown will not wait for your tasks to finish. It calls ExitProcess, which effectively terminates all threads, including the thread pool that services the Tasks.



                  As @Ryan Pierce Willems wrote, you need to call Task.WaitAll to make sure you wait for all tasks to complete.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 12 '18 at 17:31









                  NickNick

                  2,0481213




                  2,0481213













                      Popular posts from this blog

                      𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                      Crossroads (UK TV series)

                      ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế