Click here to Skip to main content
15,799,398 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# List of Tasks Pin
Kevin Marois6-Apr-23 20:45
professionalKevin Marois6-Apr-23 20:45 
GeneralRe: C# List of Tasks Pin
OriginalGriff6-Apr-23 21:21
mvaOriginalGriff6-Apr-23 21:21 
GeneralRe: C# List of Tasks Pin
Kevin Marois6-Apr-23 21:22
professionalKevin Marois6-Apr-23 21:22 
GeneralRe: C# List of Tasks Pin
OriginalGriff6-Apr-23 22:50
mvaOriginalGriff6-Apr-23 22:50 
GeneralRe: C# List of Tasks Pin
OriginalGriff6-Apr-23 22:58
mvaOriginalGriff6-Apr-23 22:58 
AnswerRe: C# List of Tasks Pin
lmoelleb7-Apr-23 2:54
lmoelleb7-Apr-23 2:54 
AnswerRe: C# List of Tasks Pin
jschell7-Apr-23 10:20
jschell7-Apr-23 10:20 
AnswerRe: C# List of Tasks Pin
Richard Deeming10-Apr-23 22:27
mveRichard Deeming10-Apr-23 22:27 
Assuming you have a list of tasks which return the same type, and you want to process the task results in the order in which they complete, then Stephen Toub has you covered:
Processing tasks as they complete - .NET Parallel Programming[^]

For a small number of tasks, using Task.WhenAny is probably good enough:
C#
var tasks = new List<Task<T>>
{
    _apiProxy.GetNavigationItems(NavigationItemType.Company),
    _apiProxy.GetNavigationItems(NavigationItemType.Employee),
    _apiProxy.GetNavigationItems(NavigationItemType.Project)
};

while (tasks.Count != 0)
{
    var t = await Task.WhenAny(tasks);
    tasks.Remove(t);
    
    T result = await t;
    // Process the results here...
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

QuestionPassword Regex Help Pin
Jassim Rahma28-Mar-23 10:41
Jassim Rahma28-Mar-23 10:41 
AnswerRe: Password Regex Help Pin
Dave Kreskowiak28-Mar-23 12:21
mveDave Kreskowiak28-Mar-23 12:21 
AnswerRe: Password Regex Help Pin
OriginalGriff28-Mar-23 20:55
mvaOriginalGriff28-Mar-23 20:55 
AnswerRe: Password Regex Help Pin
Eddy Vluggen1-Apr-23 7:31
professionalEddy Vluggen1-Apr-23 7:31 
AnswerRe: Password Regex Help Pin
Member 115612954-Apr-23 0:50
Member 115612954-Apr-23 0:50 
QuestionRe: Password Regex Help Pin
Eddy Vluggen14-Apr-23 7:41
professionalEddy Vluggen14-Apr-23 7:41 
AnswerRe: Password Regex Help Pin
Ravi Bhavnani15-Apr-23 11:52
professionalRavi Bhavnani15-Apr-23 11:52 
AnswerRe: Password Regex Help Pin
Bohdan Stupak19-Apr-23 4:28
professionalBohdan Stupak19-Apr-23 4:28 
Questioncreate our own unit testing framework in C# Pin
Sakhalean26-Mar-23 19:32
Sakhalean26-Mar-23 19:32 
AnswerRe: create our own unit testing framework in C# Pin
OriginalGriff26-Mar-23 22:00
mvaOriginalGriff26-Mar-23 22:00 
AnswerRe: create our own unit testing framework in C# Pin
jschell27-Mar-23 8:00
jschell27-Mar-23 8:00 
AnswerRe: create our own unit testing framework in C# Pin
Gerry Schmitz27-Mar-23 12:39
mveGerry Schmitz27-Mar-23 12:39 
GeneralRe: create our own unit testing framework in C# Pin
mtoha13-Apr-23 17:39
professionalmtoha13-Apr-23 17:39 
QuestionManagement of window coordinates and sizes for multiple screens of different resolutions Pin
temuco25-Mar-23 14:14
professionaltemuco25-Mar-23 14:14 
AnswerRe: Management of window coordinates and sizes for multiple screens of different resolutions Pin
OriginalGriff25-Mar-23 21:18
mvaOriginalGriff25-Mar-23 21:18 
GeneralRe: Management of window coordinates and sizes for multiple screens of different resolutions Pin
temuco26-Mar-23 2:22
professionaltemuco26-Mar-23 2:22 
GeneralRe: Management of window coordinates and sizes for multiple screens of different resolutions Pin
Dave Kreskowiak26-Mar-23 6:38
mveDave Kreskowiak26-Mar-23 6:38 

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.