timer question...

lidds

Junior Contributor
Joined
Nov 9, 2004
Messages
210
As I am new to VB.net, would it be bad practice to have a time on my application to check a small database table every 10 mins? Would this slow performance on my application?

Cheers

Simon
 
By slowing performance what do u mean? Like if the application freezes for a couple of seconds? If thats a problem for u, u can have a timer start a seperate thread every 10 minutes.
 
What do you mean by start a seperate thread (sorry new to vb.net)?

The querying of the database would not take that long, probably 10secs.... but I really want to do this but without stoping other users from using the app.
 
Code:
'Declarations part of Form

Dim MyThread as System.Threading.Thread

Sub Timer1_Tick
MyThread=New System.Threading.Thread(Addressof TableCheck)
MyThread.Start 
end sub

Sub TableCheck() '<- Notice that u are not allowed to pass any parameters
'Do the check of the table here
end sub

Try to read some general info about threads in order to find what they are exactly. After you understand them, you will be able to manipulate them to fit your needs. Imagine a thread as running a separate 'subprogram' from withing your program (thats not too accurate but it helps to visualize it).
Like if u have Notepad and Paint open at the same time and paint is busy, notepad will not be affected. Thats because they are running on different threads. The same idea applies here(in an abstract kind of way)
 
Thanks for the help, am currently reading up on Thread, will be experimenting tonight with them.

I have another question as well, not exsacually related to the above, but thought as I got such a good and quick response I'll post it anyway.

I am writing an application that the database and application will be loaded on a server, then have multiple clients accessing the exe from the server on different machines. Obviously there could be conflicts if two users send an update query to the database to update the same record. There would probably only be about 20 users at a time who would have access to update records and the other users would be read-only. So what I was proposing to do is when the user switches to a record using the app. I would write true to a lock field on that record (only if readonly) therefore if another user navigates to the same record then it will only give then read-only and notify them that this record is locked untill the user who locked it moves on and the lock field is set to false.

Is this bad practice or is there a better way of doing this?

Also there should only be one user who will be writing data to that record and this is the way I want the app. to work

Cheers

Simon
 
I think i read an article on that somewhere... You are actually trying to make some sort of SQL server thing. Why dont u use microsoft's SQL server? As far as the record locking is concerned i think that field is a decent way to do it, maybe storing there who is currently viewing the info so when a user gets readonly permission, he can know who is blocking him (i would do it this way in our office so they wouldnt come bugging me about the record being read only).
 
I will be using SQL server for deployment if it takes off, so currently am using MSDE as it free :D

Thanks for your help
 
lidds said:
I will be using SQL server for deployment if it takes off, so currently am using MSDE as it free :D

Thanks for your help

MSDN and Sql server use the same engine.. just msdn is goverened. I'd relie on sql server locking to do your locking. If your sql code is clean, the design sound and proper indexes on your database tables.. you shouldn't having locking problems. (or very few). also if you use stored procedures to do your sql work.. that can help. I'm pretty new to VB.net.. not very good at it.. but been doing sql for quite a while. The only applicitions that I have lots of blocking and locking problems with are those that use a lot of cursors for to do their sql work with. The applicationsn that use set based sql calls with even decent indexing and decent db design don't have problems. The database I have to deal with aren't huge.. ~300 users.
 
Back
Top