Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
AnswerRe: Audio programming - play section of WAV file Pin
BillWoodruff31-Aug-13 1:47
professionalBillWoodruff31-Aug-13 1:47 
AnswerRe: Audio programming - play section of WAV file Pin
blitzkrieged31-Aug-13 13:31
blitzkrieged31-Aug-13 13:31 
AnswerRe: Audio programming - play section of WAV file Pin
blitzkrieged31-Aug-13 21:01
blitzkrieged31-Aug-13 21:01 
AnswerRe: Audio programming - play section of WAV file Pin
Dusara Maulik31-Aug-13 23:27
Dusara Maulik31-Aug-13 23:27 
QuestionCan we use memorycache in webservice running on different machine and client on other machine?(c#) Pin
santosh code30-Aug-13 19:30
santosh code30-Aug-13 19:30 
AnswerRe: Can we use memorycache in webservice running on different machine and client on other machine?(c#) Pin
Pete O'Hanlon30-Aug-13 22:04
mvePete O'Hanlon30-Aug-13 22:04 
GeneralRe: Can we use memorycache in webservice running on different machine and client on other machine?(c#) Pin
santosh code31-Aug-13 0:34
santosh code31-Aug-13 0:34 
Question[Solved] Run application until Tasks are finished? Pin
Dralken30-Aug-13 13:54
Dralken30-Aug-13 13:54 
I'm writing an application that performs a few independant tasks in the background. It's a console application.

My issue is that when the program is run, it starts to execute some of the stuff on the threads (processes maybe 1-2 lines of code) then quits before all the tasks are finished (I'm using the Task library, rather than standard Threads)

Rather than cramming all of my code into the Main() function, I'm separating them out into different functions for readability.

If I add a Console.ReadKey() at the end of the Main function, all the tasks run properly (they only take maybe 1-2 seconds, though over time that could change to several minutes, as it's performing file operations) and close properly when I hit a button.

However, once I'm finished with it, I don't want to have make the user do any inputs (it's going to be a "scheduled" task), in fact the window won't even be shown.

Part of my problem is that, by the nature of my program, I can't ever be completely sure of how many tasks are going to be running. The program pulls in a list of what needs to be done from an xml file.

Is there a safe way to perhaps create a list of tasks, then at the end of the Main() function, have it wait till all those tasks are complete before the program closes?

I tried using a
List<Task>
but it didn't seem very safe, as I'd be building the array with other functions then doing a foreach() on the list and starting each task.

modified 31-Aug-13 7:33am.

AnswerRe: Run application until Tasks are finished? Pin
Dave Kreskowiak30-Aug-13 14:57
mveDave Kreskowiak30-Aug-13 14:57 
GeneralRe: Run application until Tasks are finished? Pin
Dralken30-Aug-13 15:16
Dralken30-Aug-13 15:16 
GeneralRe: Run application until Tasks are finished? Pin
Dave Kreskowiak30-Aug-13 15:28
mveDave Kreskowiak30-Aug-13 15:28 
GeneralRe: Run application until Tasks are finished? Pin
Dralken31-Aug-13 1:26
Dralken31-Aug-13 1:26 
GeneralRe: Run application until Tasks are finished? Pin
BillWoodruff1-Sep-13 19:51
professionalBillWoodruff1-Sep-13 19:51 
GeneralRe: Run application until Tasks are finished? Pin
Dralken1-Sep-13 20:40
Dralken1-Sep-13 20:40 
SuggestionRe: Run application until Tasks are finished? Pin
Keith L Robertson3-Sep-13 5:27
Keith L Robertson3-Sep-13 5:27 
QuestionHow to solve this error "safe handle has been closed"? Pin
vikash kumar NIIT29-Aug-13 23:16
vikash kumar NIIT29-Aug-13 23:16 
SuggestionRe: How to solve this error "safe handle has been closed"? Pin
Richard Deeming30-Aug-13 1:38
mveRichard Deeming30-Aug-13 1:38 
GeneralRe: How to solve this error "safe handle has been closed"? Pin
vikash kumar NIIT30-Aug-13 1:50
vikash kumar NIIT30-Aug-13 1:50 
GeneralRe: How to solve this error "safe handle has been closed"? Pin
davidstein30-Aug-13 3:06
davidstein30-Aug-13 3:06 
GeneralRe: How to solve this error "safe handle has been closed"? Pin
Richard Deeming30-Aug-13 3:21
mveRichard Deeming30-Aug-13 3:21 
Questionhow to get balance by USSD commands? Pin
davidstein29-Aug-13 22:58
davidstein29-Aug-13 22:58 
SuggestionRe: how to get balance by USSD commands? Pin
Richard MacCutchan30-Aug-13 0:03
mveRichard MacCutchan30-Aug-13 0:03 
GeneralRe: how to get balance by USSD commands? Pin
davidstein30-Aug-13 1:04
davidstein30-Aug-13 1:04 
GeneralRe: how to get balance by USSD commands? Pin
Dave Kreskowiak30-Aug-13 2:42
mveDave Kreskowiak30-Aug-13 2:42 
GeneralRe: how to get balance by USSD commands? Pin
davidstein30-Aug-13 3:05
davidstein30-Aug-13 3:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.