I would like EndGetMatches in the code below to get called when a certain event is fired. BeginGetMatches executes and completes but I don't want EndGetMatches to get called yet. I want to return the ActionResult only when my other Thread notifies me i'm ready to.
public delegate void MatchEvent(MatchEventArgs args);
public IAsyncResult BeginGetMatches(string privateId, string publicId, AsyncCallback callback, object state) {
// pseudo code
// Matcher is a running thread
Matcher matcher = Matcher.getInstance();
// When matches are ready, call matchesReady() .. this might be after 2 secs for example
matcher.add(privateId, publicId, new MatchEvent(matchesReady));
// return something
}
// gets called back when the Matcher decides so
public void matchesReady(MatchEventArgs args) {
// call EndGetMatches somehow and return Response to client
}
public ActionResult EndGetMatches(IAsyncResult result)
{
}
Am I making sense here?