private void AsyncFunctionCallBack(IAsyncResult r) // Async Call Completes { AsyncResult result = (AsyncResult)r; AsyncPetFunctionPointer caller = (AsyncPetFunctionPointer)result.AsyncDelegate; caller.EndInvoke(r); }
public Player() { // Generate pet data object and init Pet instance with 500 random number PetPersistence p = new PetPersistence("Ninja", BuildStory()); //or assign a known int array so that it can be UNIT tested easily as the output would be exactly same. pet = new Pet(this, p); //Set function pointers for Async Calls to Pet thread feed = new AsyncPetFunctionPointer(pet.FeedGiven); bed = new AsyncPetFunctionPointer(pet.BedGiven); clean = new AsyncPetFunctionPointer(pet.CleanGiven); sendkey = new AsyncSendKeyFunctionPointer(pet.ControlKeyGiven); // Start Pet thread petThread = new Thread(new ThreadStart(pet.Start)); }