Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

timer update

$
0
0

Hello,

I want to check and update data in background with timer but does not works.

protected void Timer2_Tick(object sender, EventArgs e)
    {
        DateTime currentDateTime = DateTime.Now;

        Button1.Text = currentDateTime.ToString();

        var results = (from t1 in db.tbl_Events where t1.DateTimeForLastPayment < DateTime.Now && t1.IsApproved == true select t1);

        foreach (var hasWon in results)
        {
            Random random = new Random();
            int randomNumber = random.Next(0, 180);
            double number = Math.Ceiling(random.NextDouble() * 2000 * 1000) * 0.0001;

            //  double currentStreak = randomFloat(number, number);//random.Next(number,number);


            hasWon.Payment = hasWon.Payment + Convert.ToDecimal(number++);
            hasWon.DateTimeForLastPayment = Convert.ToDateTime(currentDateTime.AddSeconds(randomNumber));

            db.SubmitChanges();
        }
<asp:Timer ID="Timer2" runat="server" Interval="1" OnTick="Timer2_Tick"></asp:Timer>



Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>