I am implementing an interface which requires implementations of BeginDoSomething
and EndDoSomething
methods. However my DoSomething
isn't really long-running.
For simplicity assume DoSomething
only compares two variables and return whether a > b
So my BeginDoSomething should be like:
protected override IAsyncResult BeginDoSomething(int a, int b, AsyncCallback callback, object state)
{
bool returnValue = a > b;
return ...; //what should I return here?
//The method actually already completed and I don't need to wait for anything
}
I don't know what I should return. I only implement BeginDoSomething
because I have to, not because my method is long-running. Do I need to implement my own IAsyncResult
? Is there an implementation already in .NET libraries?