private void btnContinue_Click(object sender, EventArgs e) { // Store all of the information we need to restore our state if we fail int groupIndex_temp = group.GetIndex(); int index_temp = index; // We have to Deep Copy this data List <int> healVals_temp = new List <int>(healVals); CircularBuffer <uint> searchBuff_temp = searchBuff.DeepClone(); IRNG rng_temp = searchRNG.DeepClone(); group.IncrimentIndex(); if (!FindNext(int.Parse(tbLastHeal.Text))) { // Restore state group.SetIndex(groupIndex_temp); index = index_temp; // No Deep Copy needed here. We can just re-assign the temps // because we won't be touching them again. healVals = healVals_temp; searchBuff = searchBuff_temp; searchRNG = rng_temp; MessageBox.Show("Impossible Heal Value entered."); return; } int numRows = ParseNumRows(); displayRNG(index - healVals.Count + 1, index + numRows); }
/// <summary> /// Continue rng search based on last heal value and current heal value /// </summary> /// <returns></returns> private async Task ContinueAsync() { await RunCommandAsync(() => IsBusy, async() => { // TODO: make all this logic asyncronous. int groupIndex_temp = mGroup.GetIndex(); int index_temp = mIndex; List <int> healVals_temp = new List <int>(mHealVals); CircularBuffer <uint> searchBuff_temp = mSearchBuff.DeepClone(); IRNG rng_temp = mSearchRng.DeepClone(); mGroup.IncrimentIndex(); if (!FindNext(LastHeal)) { mGroup.SetIndex(groupIndex_temp); mIndex = index_temp; mHealVals = healVals_temp; mSearchBuff = searchBuff_temp; mSearchRng = rng_temp; await mPage.DisplayAlert("Alert", "Impossible Heal Value entered", "OK"); } else { DisplayRNG(mIndex - mHealVals.Count + 1, mIndex + 1000); } }); }