What is the closest equivalent to Java's Future<T>
in C#?
For example, what would the closest reconstruction of the following be in C#:
public class FutureMethodCall implements Future {
private Future<APIResponse> methodCall;
public boolean cancel(boolean mayInterruptIfRunning) {
return this.methodCall.cancel(mayInterruptIfRunning);
}
public APIResponse get() throws ExecutionException, InterruptedException {
return this.methodCall.get();
}
...
}
Thanks in advance!
I'm not sure what a Future does in Java, but from the code it looks like you are executing code at a later time that runs asyncronously and is cancelable.
Have a look at Tasks in C#, they offer the same capabilities.