如何在没有使用ASP.NET C#闪烁的情况下使用计时器?

编程入门 行业动态 更新时间:2024-10-10 07:23:25
本文介绍了如何在没有使用ASP.NET C#闪烁的情况下使用计时器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

正在创建一个生日屏幕,我需要将Bday图像显示为背景,并在Bday日期显示员工详细信息... 因此所有细节将显示背景。但唯一的事情是每次定时器旋转时背景都会闪烁.. 如何解决闪烁问题??? 请做好我需要的事情团队......

Am creating a birthday screen where I need to display Bday images as background and also to display employee details on Bday date... As a result all details with background will display. But the only thing is background flickers every time of timer rotation.. How to solve the flickering??? Please do the needful team...

Here is my Code: protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { CompID = objGlobal.HRCompanyID; BindNextImage(); } } catch (Exception ex) { } return; } protected void Timer1_Tick(object sender, EventArgs e) { BindNextImage(); } public void BindNextImage() { try { ClearControls(); Random _rand = new Random(); dtData = objTvImage.getImage(CompID); int i = _rand.Next(0, dtData.Rows.Count); lblCompName.Text = dtData.Rows[i]["CompanyName"].ToString(); lblDepName.Text = dtData.Rows[i]["Department"].ToString(); lblEmpName.Text = dtData.Rows[i]["Name"].ToString(); lblMonth.Text = dtData.Rows[i]["Designation"].ToString(); lblDate.Text = dtData.Rows[i]["Date Of Birth"].ToString(); GetImage((byte[])dtData.Rows[i]["Image"]); //To get templates if (lblDate.Text == "TRANSFER") { pnlImage.BackImageUrl = "~/Images/" + "TRAN.jpg"; } else if (lblDate.Text == "PROMOTED") { pnlImage.BackImageUrl = "~/Images/" + "PRO.jpg"; } else { int day = (int)System.DateTime.Now.Day; pnlImage.BackImageUrl = "~/Images/" + "BDay" + day.ToString() + ".jpg"; } } catch (Exception ex) { } } }

我尝试过: 请参考上面的代码..

What I have tried: Please refer the above code..

推荐答案

可能不是计时器本身,但你显示导致问题的数据的方式 - 没有看到你的代码,我们无法告诉你如何解决它。如果您在计时器中所做的只是使表单或面板失效,那么这可能会导致闪烁,因为背景被擦除并重新绘制,例如。 你可以通过将Form.DoubleBuffered属性设置为 true 来减少或消除问题,但我首先要查看用于在计时器时绘制内容的代码。碰巧。 Probably, it's not the timer itself, but the way you are displaying the data that is causing the problem - and without seeing your code we can't tell you what to do to fix it. If all you are doing in the timer is Invalidating the form or the panel, then that could cause the flicker as the background is erased and redrawn, for example. You may be able to reduce or eliminate the problem by setting the Form.DoubleBuffered property to true, but I'd start by looking at teh code you use to draw things when the Timer.Tick happens.

更多推荐

如何在没有使用ASP.NET C#闪烁的情况下使用计时器?

本文发布于:2023-11-07 15:46:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566855.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:计时器   情况下   如何在   NET   ASP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!