'Async Methods overwriting previous call

I am writing a console application wherein I'm using async calls to another method. I have the same call happening twice with different overloads. When I'm debugging I can see that the first call got the correct information but when the second call finishes the first call variable is overwritten with the second call's results.

Its literally 2 lines of code that are giving me issues.

var myParty = await _partyService.GetParty(Context.User.Id);
var compParty = await _partyService.GetParty(0);

myParty will initially have the correct values, but when compParty populates, myParty changes to match it.

edit: as requested my _partyService GetParty Class.

public async Task<List<CreatureBase>> GetParty(ulong playerID)
        {
            try
            {
                List<CreatureBase> party = new List<CreatureBase>();

                Dictionary<ulong, string> partyMembers = new Dictionary<ulong, string>();
                partyMembers.Add(0, "Testy");

                foreach (var pM in partyMembers)
                {
                    var cList = await _creatureService.GetCreatureList();
                    var c = cList.Where(x => x.Key == pM.Value).FirstOrDefault();

                    var newCreature = await _creatureService.GetCreatureStats(playerID, c.Value);

                    party.Add(newCreature);
                }

                return party;
            }
            catch (Exception ex)
            {
                return null;
            }
        }

as i said previously, this does return the 2 different results expected, but myParty gets changed when this returns the second result to compParty



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source