读书人

为什么在timer事件中始终无法正确弹出

发布时间: 2012-02-25 10:01:49 作者: rapoo

为什么在timer事件中始终无法正确弹出小纸条,在线等,谢谢
大家好,请问一下,我的程序里需要隔上5秒就检测数据库是不是更新,如果是,弹出MSN小纸条提示.
现在我设置了一个timer,(Web版),为什么小纸条始终就不弹出呢,如果把那段代码不放在timer事件中,执行正确.
下面是代码,请指点一下哪里不合适,谢谢,着急,在线等.

'属性
Timer1.Interval=10000

'代码
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
If m_IsWorking Then
Return
End If
m_IsWorking = True
' 开始调用方法
workAsynchronism()
m_IsWorking = False

End Sub

Private Sub workAsynchronism()
Try
Dim TableName As String = "TroubleList"
Dim sql As String = "(DEPTID='" + sDeptCode + "' or AppointDEPTID='" + sDeptCode + "' or DEPTID1='" + sDeptCode + "'or DEPTID2='" + sDeptCode + "' or DEPTID3='" + sDeptCode + "' or DEPTID4='" + sDeptCode + "') and (STATE<>'成功') "
Dim strsql As String = " and STATE='接收' "
Dim iRecordNum As Integer = GetRecordNum("Select Count(*) as CountNum From " & TableName & " Where " & sql + strsql)
If iRecordNum > 0 Then
Timer1.Enabled = False
'Dim Result As Long = sndPlaySound(SoundFile, 1)

popupWin.ActionType = EeekSoft.Web.PopupAction.OpenLink
popupWin.Message = "您有" + iRecordNum.ToString() + "个单需要处理"
popupWin.Link = "WebFaultDataForm.aspx"
popupWin.LinkTarget = "_self"
'使用默认方式
'设置颜色风格
popupWin.ColorStyle = EeekSoft.Web.PopupColorStyle.Blue
'设置窗口弹出和消失的时间
popupWin.HideAfter = 5000
popupWin.ShowAfter = 500
popupWin.Visible = True

Else
Timer1.Enabled = True
End If

Catch ex As Exception
Dim sError As String = ""
sError = ex.Message

End Try
End Sub



[解决办法]
up.
[解决办法]
把更新popupWin的代码,
放到一个代理函数里面,然后用Me.Invoke来调用

[解决办法]
web版是不支持TIMER的呀
[解决办法]
文章地址发错了,在
http://blog.csdn.net/peak915/archive/2005/07/14/424503.aspx
[解决办法]
使用前台的事件,<script Language=JavaScript>
window.setTimeout('this.location.reload();',600000);
</script>
或者在HTML的方法中定义<meta http-equiv="refresh" content="600">

读书人网 >VB Dotnet

热点推荐