collection of methods to run AWAIT sequentially

  • Thread starter Thread starter harry_777
  • Start date Start date
H

harry_777

Guest
Hi,

I have a bunch of async Task<T>methods like:

public async Task<string> Method1(int i, string s){ return s;}
public async Task<string> Method2() {return "out";}
public async Task<bool> Method3() {return true;}


Is there a way I can create a collection like:

public class MethodsCollection
{
public string PreText { get; set; }
public Delegate FunctionName { get; set; }
}

List<MethodsCollection> methods = new List<MethodsCollection>();
methods.Add(new MethodsCollection{ PreText = "", FunctionName = new Func<int, string, Task<string>>(Method1)});
methods.Add(new MethodsCollection{ PreText = "", FunctionName = new Func<string, Task<string>>(Method2)});
methods.Add(new MethodsCollection{ PreText = "", FunctionName = new Func<Task<bool>>(Method3)});

and then loop through every method - BUT using AWAIT - I want them to run sequentially:


Thanks in advance.
Harry

Continue reading...
 

Similar threads

I
Replies
0
Views
107
IndigoMontoya
I
C
Replies
0
Views
85
Craig Muckleston (MCPD, MCTS)
C
Back
Top