TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maik Brauer
NA
12
43.2k
Threading to write LogFiles
Nov 27 2010 6:27 PM
Hi,
to speed up my application I implemented the Threading in order to write some loginfos into the SQL-Server.
So I make use of a Thread to Insert a row into the DB. The problem is that sometimes the Thread will be used 2 or 3 times very
fast after each other, which means I am calling 3 times the Thread method. Each of the Task will write a timestamp into the DB.
So now the problem is, that if all 3 thread have been started T2 starts writing into the DB earlier that T1, even though that the T1 has started first.
But due to the Operating System the T1 has been delayed and the T2 has started faster. So my Logfile entry are not showing any Chronological order.
How can I make sure that, just one operation has been finished before the 2 will be written. Please be aware, that I'm not talking about 3 Threads starting in parallel.
It is always the same Call to invoke, see below:
Private Sub LogBookManager()
Dim LogBookThread As New Thread(AddressOf LogBookStreamer)
LogBookThread.Priority = ThreadPriority.Normal
LogBookThread.IsBackground = True
LogBookThread.Start()
End Sub
If I would try to insert "LogBookThread.Join()" then I would make the Thread sequential. Then there is no benefit of using Threading
and the whole application will slow down, during that Operation.
Can somebody help me here in order to get it solved.
Thanks.
Cheers,
Maik
Reply
Answers (
0
)
How to add Master Page like web in windows form?
How to style the Tabs from TabControl?