public void ExecuteAuctionRound() { List <Task> tasks = new List <Task>(); List <Raiser> raisers = new List <Raiser>(); object _lock = new object(); if (UpdateAuction != null) { Parallel.ForEach(UpdateAuction.GetInvocationList(), item => { tasks.Add(Task.Factory.StartNew(() => { lock (_lock) raisers.Add((Raiser)item.DynamicInvoke(Price, JumpOfPrice)); })); }); } Task.WaitAll(tasks.ToArray()); if (raisers != null) { var check = raisers.OrderByDescending(item => item.RaisePrice).First(); if (check.RaisePrice > Price) { Price = check.RaisePrice; MaxRaiser = check; } } }
public Auction(int id, IItem product, int price, int jumpofprice, DateTime startDateTime) { Id = id; Product = product; Price = price; JumpOfPrice = jumpofprice; StartDateAndTime = startDateTime; IsOpen = false; Agents = new List <IAgent>(); MaxRaiser = new Raiser(); }