on-internet
← Community

Will This C# Generic Method Handle Async Properly?

Stack Overflow ·

I have some C# code (in a .NET Standard 2.0 library) that looks like the following: private object MySynchronousOp(object param, object cmnParam) { //Do stuff... return theObject; } private ResponseT Do<ResponseT, RequestT>(Func<RequestT, object, ResponseT> op, RequestT request) { //Do some checks, get/setup cmnParam. return op.Invoke(request, cmnPatam); } public object RunMySynchronousOp(object param) { return Do(MySynchronousOp, param); } This pattern is repeated for many MySynchronousOp and RunMySynchronousOp pairs, using Do to do a common set of checks and provide a valid common parameter.

Comments

Sign in or sign up to comment and upvote.

No comments yet.