0

I asked a several time but must ask again, beacuse I don't know what to do: On my Page I have an auctioneer system.

Every second I must:

  • Get Information if any bidder bid on it -> Database Query
  • Countdown the timer minus 1 second
  • Update a few panel with information if there is a new bidder (history that is shown, bla)

My (funny) problem is, that only a simple ASP.Net Ajax timer (which I must have I think because I need the DAL and so on) in an Updatepanel with only the Label-Timer and a countdown of that need more then 1 single second...

That mean, when I run the timer, which only Converts the Label to DateTime, remove 1 second and update the label, in 10 normal seconds it not run 10 times, only 8 times.

So in 10 Seconds I lose 2 seconds...

I don't want to image when I begin to query the database within....

What to do?


I found out that it isn't the Performence that is too slow. The timer does'nt start every second.

I filled a Debug.Writeline with Millisecond start and end of the timer tick, here are 3 examples:

  • 2009.11.18 13:13:21:1821
  • 2009.11.18 13:13:21:1821
  • 2009.11.18 13:13:22:7021
  • 2009.11.18 13:13:22:7021
  • 2009.11.18 13:13:24:2421
  • 2009.11.18 13:13:24:2421

So it end within milliseconds, but it start again not at the right intervall (1000 milliseconds should it be!)


As wished the code:

      protected void Timer1_Tick(object sender, EventArgs e)
    {
        System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss:ffff"));
        DateTime dt = DateTime.Parse(lblTimer.Text);
        dt = dt.AddSeconds(-1.0);
        lblTimer.Text = dt.ToString("HH:mm:ss");
        System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss:ffff"));
    }

2)

                            <asp:UpdatePanel ID="up1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
    <asp:Timer ID="timeAD" Interval="1000" Enabled="true" runat="server" ontick="Timer1_Tick">
</asp:Timer>
<asp:Label ID="lblTimer" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
5
  • I would get the server to provide all the relevant details, i.e. bids on the item and the remaining auction time. The client shouldn't be doing that calculation for the very reason you have described, the client system only has to heavily loaded and you will start to miss cycles. Commented Nov 18, 2009 at 12:07
  • Yes of curse the serer do calculation and so on, it's in an Business class. Commented Nov 18, 2009 at 12:14
  • See edit please. The start of the timer seems to be every 1,4-1,6 second instead of 1 second. Can it be, that the response time is 200-300 milliseconds (x2 because double way) and the timer start the tick-intervall after it get's the first back? Commented Nov 18, 2009 at 12:20
  • Can you post your code please, I'm not sure I'm understanding how the countdown timer is being implemented. Commented Nov 18, 2009 at 12:22
  • See edit. It fills by the page load (if it is a postback) with value of 30 minutes Commented Nov 18, 2009 at 12:26

1 Answer 1

1

I know the answer now: The timer is in the Update-Panel, so the 300 milliseconds go-throug-time will be added, because the timer is restartet every imaginery postback.

Put the timer out of the update-panel and get a trigger in the panel -> Win. The timer ticks every 1 second.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.