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...
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...