473,387 Members | 1,440 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,387 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 1692
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.