c# - Passing a method with parameter Func and getting TResult -


So basically there is a return type in T, I want to return the generic return type. Example: Private trace endwolf & lt; T, TResult & gt; (Funk & lt; T, TResult & gt; asyncCaller, IAsyncResult asyncResult) {Trust Result = Default (TResult); Try {result = asyncCaller.EndInvoke (asyncResult); } Hold (exception exception) {// get exception details} return result; }

How do I just call T and get a trashlech? I remember, I only have t.

Edit: How do I tell this method?

Edit: I want a general interconnection, because I'm trying a lot on different endvoks, then I want results from endwoke.

I first of all used my generic endInneq & lt ;, & gt; I suggest changing the method.

  Public Stable Class FuncExtensions {Public Static Trashlutt and Invoke & lt; T, TResult & gt; (This fax & lt; T, TResult & gt; asyncCaller, IAsyncResult asyncResult) {// ...}}   

This method will make calls easier. For example, I Call a method that calculates the square of an integer.

  Private integer square (int x) {return x * x; }   

In your client code, you call it this like this:

  F & lt; Int, int & gt; Caller = new funk & lt; Int, int & gt; (Square); Int x = 5; Int y = default (int); Caller.BeginInvoke (x, asyncResult = & gt; {y = caller.EndInvoke (asyncResult);}, tap); Console.light line ("{0} is square {1}", x, y);   

Edit

This example has not been tested in any way, and there is a clear race condition in it.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -