Click here to Skip to main content
15,881,744 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# List of Tasks Pin
Kevin Marois6-Apr-23 19:45
professionalKevin Marois6-Apr-23 19:45 
GeneralRe: C# List of Tasks Pin
OriginalGriff6-Apr-23 20:21
mveOriginalGriff6-Apr-23 20:21 
GeneralRe: C# List of Tasks Pin
Kevin Marois6-Apr-23 20:22
professionalKevin Marois6-Apr-23 20:22 
GeneralRe: C# List of Tasks Pin
OriginalGriff6-Apr-23 21:50
mveOriginalGriff6-Apr-23 21:50 
GeneralRe: C# List of Tasks Pin
OriginalGriff6-Apr-23 21:58
mveOriginalGriff6-Apr-23 21:58 
AnswerRe: C# List of Tasks Pin
lmoelleb7-Apr-23 1:54
lmoelleb7-Apr-23 1:54 
AnswerRe: C# List of Tasks Pin
jschell7-Apr-23 9:20
jschell7-Apr-23 9:20 
AnswerRe: C# List of Tasks Pin
Richard Deeming10-Apr-23 21:27
mveRichard Deeming10-Apr-23 21: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 9:41
Jassim Rahma28-Mar-23 9:41 
AnswerRe: Password Regex Help Pin
Dave Kreskowiak28-Mar-23 11:21
mveDave Kreskowiak28-Mar-23 11:21 
AnswerRe: Password Regex Help Pin
OriginalGriff28-Mar-23 19:55
mveOriginalGriff28-Mar-23 19:55 
AnswerRe: Password Regex Help Pin
Eddy Vluggen1-Apr-23 6:31
professionalEddy Vluggen1-Apr-23 6:31 
AnswerRe: Password Regex Help Pin
Member 115612953-Apr-23 23:50
Member 115612953-Apr-23 23:50 
QuestionRe: Password Regex Help Pin
Eddy Vluggen14-Apr-23 6:41
professionalEddy Vluggen14-Apr-23 6:41 
AnswerRe: Password Regex Help Pin
Ravi Bhavnani15-Apr-23 10:52
professionalRavi Bhavnani15-Apr-23 10:52 
AnswerRe: Password Regex Help Pin
Bohdan Stupak19-Apr-23 3:28
professionalBohdan Stupak19-Apr-23 3:28 
Questioncreate our own unit testing framework in C# Pin
Sakhalean26-Mar-23 18:32
Sakhalean26-Mar-23 18:32 
AnswerRe: create our own unit testing framework in C# Pin
OriginalGriff26-Mar-23 21:00
mveOriginalGriff26-Mar-23 21:00 
AnswerRe: create our own unit testing framework in C# Pin
jschell27-Mar-23 7:00
jschell27-Mar-23 7:00 
AnswerRe: create our own unit testing framework in C# Pin
Gerry Schmitz27-Mar-23 11:39
mveGerry Schmitz27-Mar-23 11:39 
GeneralRe: create our own unit testing framework in C# Pin
mtoha13-Apr-23 16:39
professionalmtoha13-Apr-23 16:39 
QuestionManagement of window coordinates and sizes for multiple screens of different resolutions Pin
temuco25-Mar-23 13:14
professionaltemuco25-Mar-23 13:14 
AnswerRe: Management of window coordinates and sizes for multiple screens of different resolutions Pin
OriginalGriff25-Mar-23 20:18
mveOriginalGriff25-Mar-23 20:18 
GeneralRe: Management of window coordinates and sizes for multiple screens of different resolutions Pin
temuco26-Mar-23 1:22
professionaltemuco26-Mar-23 1:22 
GeneralRe: Management of window coordinates and sizes for multiple screens of different resolutions Pin
Dave Kreskowiak26-Mar-23 5:38
mveDave Kreskowiak26-Mar-23 5: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.