473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

background timer process Q

One more tweak to my survey program. Since all the survey records are
stored in a dataset and updated to the database only when the program
closes, I need some sort of protection against a system crash. So, I'm
trying to have a timer running that updates the database every 10 minutes.
I'm wondering if I did this right...

Module Shared Code
Public DataUpdateTimer as New System.Windows.Forms.Timer
Public Sub Main()
Dim delUpdate as new ThreadStart(AddressOf InitializeTimer)
Dim Update as new Thread(delUpdate)
Update.Start()

Sub InitializeTimer()
AddHandler DataUpdateTimer.Tick, AddressOf UpdateData

With DataUpdateTimer
.Interval = 600000
.Enabled = True
.Start()
End With
End Sub

Sub UpdateData(ByVal myObject as Object, ByVal myEventArgs as
EventArgs)
Dim InsertedRows as System.Data.Dataset =
frmMainform.dsSurveyData2.GetChanges(DataRowState. Added)
If Not InsertedRows Is Nothing Then
frmMainForm.odbdaSurvey.Update(InsertedRows)
End If
frmMainForm.dsSurveyData2.AcceptChanges()
DataUpdateTimer.Enabled = True
End Sub
End Module
Nov 21 '05 #1
2 1686
Actually, I figured it out. Amazing what you can accomplish when you're
irritated...

This is what it ended up looking like:

Module Shared Code
Public DataUpdate Timer as new System.Timers.Timer
Public Sub Main()
dim delUpdate as new ThreadStart(AddressOf InitializeTimer)
dim Update as new Thread(delUpdate)
Update.Start()
End Sub

Public Sub InitializeTimer()
AddHandler DataUpdateTimer.Elapsed, AddressOf OnTimer

With DataUpdateTimer
.Enabled = True
.Interval = 300000
.AutoReset = True
End With
End Sub

Public Sub OnTimer(ByVal source As Object, ByVal e as
ElapsedEventArgs)
frmMainForms.odbdaSurvey.Update(frmMainform.dsSurv eyData2)
End Sub
End Module

Although I didn't get any responses, thanks to all those who helped me with
my previous questions.

"Martin Williams" <ma*******@comcast.net> wrote in message
news:CJ********************@comcast.com...
One more tweak to my survey program. Since all the survey records are
stored in a dataset and updated to the database only when the program
closes, I need some sort of protection against a system crash. So, I'm
trying to have a timer running that updates the database every 10 minutes.
I'm wondering if I did this right...

Module Shared Code
Public DataUpdateTimer as New System.Windows.Forms.Timer
Public Sub Main()
Dim delUpdate as new ThreadStart(AddressOf InitializeTimer)
Dim Update as new Thread(delUpdate)
Update.Start()

Sub InitializeTimer()
AddHandler DataUpdateTimer.Tick, AddressOf UpdateData

With DataUpdateTimer
.Interval = 600000
.Enabled = True
.Start()
End With
End Sub

Sub UpdateData(ByVal myObject as Object, ByVal myEventArgs as
EventArgs)
Dim InsertedRows as System.Data.Dataset =
frmMainform.dsSurveyData2.GetChanges(DataRowState. Added)
If Not InsertedRows Is Nothing Then
frmMainForm.odbdaSurvey.Update(InsertedRows)
End If
frmMainForm.dsSurveyData2.AcceptChanges()
DataUpdateTimer.Enabled = True
End Sub
End Module

Nov 21 '05 #2
Actually, I figured it out. Amazing what you can accomplish when you're
irritated...

This is what it ended up looking like:

Module Shared Code
Public DataUpdate Timer as new System.Timers.Timer
Public Sub Main()
dim delUpdate as new ThreadStart(AddressOf InitializeTimer)
dim Update as new Thread(delUpdate)
Update.Start()
End Sub

Public Sub InitializeTimer()
AddHandler DataUpdateTimer.Elapsed, AddressOf OnTimer

With DataUpdateTimer
.Enabled = True
.Interval = 300000
.AutoReset = True
End With
End Sub

Public Sub OnTimer(ByVal source As Object, ByVal e as
ElapsedEventArgs)
frmMainForms.odbdaSurvey.Update(frmMainform.dsSurv eyData2)
End Sub
End Module

Although I didn't get any responses, thanks to all those who helped me with
my previous questions.

"Martin Williams" <ma*******@comcast.net> wrote in message
news:CJ********************@comcast.com...
One more tweak to my survey program. Since all the survey records are
stored in a dataset and updated to the database only when the program
closes, I need some sort of protection against a system crash. So, I'm
trying to have a timer running that updates the database every 10 minutes.
I'm wondering if I did this right...

Module Shared Code
Public DataUpdateTimer as New System.Windows.Forms.Timer
Public Sub Main()
Dim delUpdate as new ThreadStart(AddressOf InitializeTimer)
Dim Update as new Thread(delUpdate)
Update.Start()

Sub InitializeTimer()
AddHandler DataUpdateTimer.Tick, AddressOf UpdateData

With DataUpdateTimer
.Interval = 600000
.Enabled = True
.Start()
End With
End Sub

Sub UpdateData(ByVal myObject as Object, ByVal myEventArgs as
EventArgs)
Dim InsertedRows as System.Data.Dataset =
frmMainform.dsSurveyData2.GetChanges(DataRowState. Added)
If Not InsertedRows Is Nothing Then
frmMainForm.odbdaSurvey.Update(InsertedRows)
End If
frmMainForm.dsSurveyData2.AcceptChanges()
DataUpdateTimer.Enabled = True
End Sub
End Module

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Eric Adem | last post by:
I have a JavaScript routine that runs on a timer and updates the position of a background image using the CSS background-position property. In Internet Explorer, it changes the mouse pointer to an...
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
2
by: DaveF | last post by:
I am trying to write a service to fire an ftp object off. I want to wait 2 minutes and then download the files. Then repeat every 2 minutes. The files just seem to stop downloading. Does that timer...
6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
2
by: John David Thornton | last post by:
I've got a Windows Service class, and I put a System.Threading.Timer, and I've coded it as shown below. However, when I install the service and then start it in MMC, I get a peculiar message: ...
6
by: cricketunes | last post by:
Hi Folks, I use PHP for a user login application and it works fine. The problem is that another process should start up as soon as the user logs in and should keep on displaying different popup...
4
by: Max | last post by:
This may be an elementary question but it's something I have not encountered in about 10 years writing code in VB 5 / 6 I have a timer that using the API checks if there has been a change to one...
2
by: Hilmar Bunjes | last post by:
Hi, I'm working on a web application in ASP.NET 3.5 and need some help with processing stuff in the background. The user who visits a web page can make reservations. Each reservation will...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.