Apologies if this question seems vague or malformed.
I'd like the following type of system in c#:
1. To be able to pipeline tasks (dataflow)
2. To choose which tasks to pipeline at runtime
I expect the "Tasks" will be methods, for which I can obtain the parameters and return types via reflection.
Does this sound like something that is feasible using TPL & Reflection?
Could anyone point me in the direction of some good resources?
I can use reflection to get method, parameter info, something like...
MethodInfo mi = myType.GetMethod("MethodName");
var parameters = mi.GetParameters();
and I've seen the documentation for simple TPL e.g. something like:
var multiplyBlock = new TransformBlock<int, int>(item => item * 2);
var subtractBlock = new TransformBlock<int, int>(item => item - 2);
multiplyBlock.LinkTo(subtractBlock);
multiplyBlock.Complete();
await subtractBlock.Completion;
But I'm not really sure how to dynamically create a TransformBlock to call the method, using the reflection information, especially for methods with multiple input parameters.
I thought of using TPL because in some cases the method(s) might be run multiple times and it would be nice to do a parallel for.
Does it seem like I am on the right track? Or am I being foolhardy?
Aucun commentaire:
Enregistrer un commentaire