示例#1
0
 /// <summary>
 /// Thread method to show the remaining time till the end of the bid
 /// It send bid results when the bid is over and update clients to prevent new bids
 /// </summary>
 /// <param name="state"></param>
 public void TimerExpired(object state)
 {
     if (auctionViewModel.TimeRemaining > 0)
     {
         Clients.All.updateRemainingTime(string.Format("{0:hh\\:mm\\:ss}", auctionViewModel.GetTimeRemaining()));
         timer.Change(sec, 0);
     }
     else
     {
         timer.Dispose();
         Clients.All.updateRemainingTime("00:00:00");
         Clients.All.finishBidding();
         AddMessage("Time Expired");
         if (!String.IsNullOrEmpty(auctionViewModel.LastUserBid))
         {
             AddMessage(string.Format("Congratulations {0}! \n {0} has won the auction with {1}$ \n on {2}", auctionViewModel.LastUserBid, auctionViewModel.ValueLastBid, auctionViewModel.LastBid));
         }
         else
         {
             AddMessage(string.Format("Oh, poor product! Somebody will take you home someday!"));
         }
     }
 }
示例#2
0
        public void TimerExpired(object state)
        {
            if (auctionViewModel.TimeRemaining > 0)
            {
                AddMessage(string.Format("Push message from server {0} - {1:hh\\:mm\\:ss}", counter++, auctionViewModel.GetTimeRemaining()));

                timer.Change(secs_10, 0);
            }
            else
            {
                timer.Dispose();
                AddMessage("Time Expired");
            }
        }