PDA

View Full Version : نحوه اجرای یک تابع هر 1 ثانیه(زمانبندی ها)



delamtangete
سه شنبه 08 مهر 1393, 08:39 صبح
من تابعی دارم که میخوام هر 1 ثانیه فراخوانی بشه
این کار رو داخل فایل Global.asax انجام دادم فقط بعد از چند دقیقه از کار می افته و تا زمانی که سایت باز نشه کار نمی کنه
اینم کد های داخل فایل هستش

Public Class Global_asax
Inherits System.Web.HttpApplication


Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application is started
Application("ActiveUsers") = 0
End Sub


Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session is started
Session.Timeout = 1
Application.Lock()
Application("ActiveUsers") = Application("ActiveUsers") + 1
Application.UnLock()
Dim myTimer As New System.Timers.Timer()
myTimer.Interval = 1000
myTimer.AutoReset = True
AddHandler myTimer.Elapsed, AddressOf myTimer_Elapsed
myTimer.Enabled = True
End Sub


Public Sub myTimer_Elapsed(ByVal source As Object, ByVal e As System.Timers.ElapsedEventArgs)
Dim JOB As New Job()
JOB.DoSomeWorkWithDB("New Server 1")
End Sub




Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires at the beginning of each request
End Sub


Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires upon attempting to authenticate the use
End Sub


Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Fires when an error occurs
End Sub


Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
Application.Lock()
Application("ActiveUsers") = Application("ActiveUsers") - 1
Application.UnLock()
End Sub


Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application ends
End Sub


End Class

saeed31641
سه شنبه 08 مهر 1393, 13:15 عصر
window.setInterval(function(){
/// call your function here
}, 5000);این با جی کویری حالا با تایمر هم می تونی خودت بنویسی

fakhravari
سه شنبه 08 مهر 1393, 15:02 عصر
http://www.dotnettips.info/post/997/%D8%A7%D8%AC%D8%B1%D8%A7%DB%8C-%D9%88%D8%B8%D8%A7%DB%8C%D9%81-%D8%B2%D9%85%D8%A7%D9%86-%D8%A8%D9%86%D8%AF%DB%8C-%D8%B4%D8%AF%D9%87-%D8%A8%D8%A7-quartz-net-%D9%82%D8%B3%D9%85%D8%AA-%D8%A7%D9%88%D9%84