Hi All
I am just double checking myself here.
I have two threads that i am running in an application, One Thread Updates a
client side Table in a local DB, another Updates a Server Side Table on a
Server DB (I know i dont like it either but for some reason they want two
seperate DB's, go figure!!)
Anyway, I use the following code to Kick off the Threads:
'While the thread state is running, loop until it is
stopped
While intRunningState <> connThread.ThreadState.Stopped
Or intRunningState2 <> connUpldThread.ThreadState.Stopped
If Not blnIsRunning Then
'Writer Updates the Screen for the User
WriteStatusUpdate(writer, "<BR><FONT
color='blue'>Retrieving Records, Please Wait....</FONT>", True)
blnIsRunning = True
connThread.Start()
intRunningState = connThread.ThreadState
connThread.Join()
connUpldThread.Start()
connUpldThread.Join()
intRunningState2 = connUpldThread.ThreadState
End If
intRunningState = connThread.ThreadState
intRunningState2 = connUpldThread.ThreadState
If connUpldThread.ThreadState = 0 Then
'Writer Updates the Screen for the User
WriteStatusUpdate(writer, "<BR><FONT
color='blue'>Sending Records, Please Wait....</FONT>", True)
End If
End While
What i want to know is, am i using the Join statement Correctly? I do want
one Thread to finish before the other starts in an effort to co-ordinate
this process. Please let me know
Thanks in advance
Samantha 2 2179
The join is correct for what you are attempting to do.
I've taken the liberty of glancing over your code. 'While the thread state is running, loop until it is stopped
logic error here. what if your thread can't talk to the database, thru
connectivity issues, OR the thread aborts or is suspended. What if the
thread fails to stop or you cannot read the thread state? Your application
enters an infinite loop. The loop is tight enough to bring down the server.
You should OR the different thread states together to test for the other
cases like aborted | suspended | stopped etc. instead of just testing for
stopped state
There is still another issue. You aren't protecting your code against a long
running thread. What if your thread decides to run for 5 hours? You have no
safeguard in the code for that. For this you may want to force an abort
after an unnecessarily long period of time.
--
Regards,
Alvin Bruney
Got Tidbits? Get it here www.networkip.net/tidbits
"Elizabeth Harmon" <EH*****@bloomingtonfarms.com> wrote in message
news:eo**************@TK2MSFTNGP09.phx.gbl... Hi All
I am just double checking myself here.
I have two threads that i am running in an application, One Thread Updates
a client side Table in a local DB, another Updates a Server Side Table on a Server DB (I know i dont like it either but for some reason they want two seperate DB's, go figure!!) Anyway, I use the following code to Kick off the Threads:
'While the thread state is running, loop until it is stopped While intRunningState <>
connThread.ThreadState.Stopped Or intRunningState2 <> connUpldThread.ThreadState.Stopped
If Not blnIsRunning Then 'Writer Updates the Screen for the User WriteStatusUpdate(writer, "<BR><FONT color='blue'>Retrieving Records, Please Wait....</FONT>", True) blnIsRunning = True connThread.Start() intRunningState = connThread.ThreadState connThread.Join() connUpldThread.Start() connUpldThread.Join() intRunningState2 = connUpldThread.ThreadState
End If intRunningState = connThread.ThreadState intRunningState2 = connUpldThread.ThreadState If connUpldThread.ThreadState = 0 Then 'Writer Updates the Screen for the User WriteStatusUpdate(writer, "<BR><FONT color='blue'>Sending Records, Please Wait....</FONT>", True) End If End While
What i want to know is, am i using the Join statement Correctly? I do want one Thread to finish before the other starts in an effort to co-ordinate this process. Please let me know
Thanks in advance
Samantha
Thanks for the Advice, i will go with a select statement in the loop so i
can test for those conditions
Samantha
"Alvin Bruney" <va******@hotspammailme.com> wrote in message
news:ud**************@TK2MSFTNGP10.phx.gbl... The join is correct for what you are attempting to do.
I've taken the liberty of glancing over your code.
'While the thread state is running, loop until it is stopped logic error here. what if your thread can't talk to the database, thru connectivity issues, OR the thread aborts or is suspended. What if the thread fails to stop or you cannot read the thread state? Your application enters an infinite loop. The loop is tight enough to bring down the
server. You should OR the different thread states together to test for the other cases like aborted | suspended | stopped etc. instead of just testing for stopped state
There is still another issue. You aren't protecting your code against a
long running thread. What if your thread decides to run for 5 hours? You have
no safeguard in the code for that. For this you may want to force an abort after an unnecessarily long period of time.
-- Regards, Alvin Bruney Got Tidbits? Get it here www.networkip.net/tidbits "Elizabeth Harmon" <EH*****@bloomingtonfarms.com> wrote in message news:eo**************@TK2MSFTNGP09.phx.gbl... Hi All
I am just double checking myself here.
I have two threads that i am running in an application, One Thread
Updates a client side Table in a local DB, another Updates a Server Side Table on
a Server DB (I know i dont like it either but for some reason they want
two seperate DB's, go figure!!) Anyway, I use the following code to Kick off the Threads:
'While the thread state is running, loop until it is stopped While intRunningState <> connThread.ThreadState.Stopped Or intRunningState2 <> connUpldThread.ThreadState.Stopped
If Not blnIsRunning Then 'Writer Updates the Screen for the User WriteStatusUpdate(writer, "<BR><FONT color='blue'>Retrieving Records, Please Wait....</FONT>", True) blnIsRunning = True connThread.Start() intRunningState = connThread.ThreadState connThread.Join() connUpldThread.Start() connUpldThread.Join() intRunningState2 =
connUpldThread.ThreadState End If intRunningState = connThread.ThreadState intRunningState2 = connUpldThread.ThreadState If connUpldThread.ThreadState = 0 Then 'Writer Updates the Screen for the User WriteStatusUpdate(writer, "<BR><FONT color='blue'>Sending Records, Please Wait....</FONT>", True) End If End While
What i want to know is, am i using the Join statement Correctly? I do
want one Thread to finish before the other starts in an effort to co-ordinate this process. Please let me know
Thanks in advance
Samantha
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Peter Hansen |
last post by:
I'm still trying to understand the behaviour that I'm
seeing but I'm already pretty sure that it's either
a bug, or something that would be considered a bug if
it didn't perhaps avoid even worse...
|
by: Paul |
last post by:
Hi,
How do I wait until a thread is finished his job then continue to the
original thread?
public void main(string args)
{
Thread t = new Thread(new ThreadStart(DoWork));
t.Start();
|
by: denton |
last post by:
I want to read a line from the textbox just like a console window. The
called thread will not allow me to enter keys when I call Join. I have stuck
on this problem for 2 weeks:
private void...
|
by: Elizabeth Harmon |
last post by:
hi all,
Just when you think you understand and are getting all this, .Net throws you
a Curve
I have the following Code
Protected Overrides Sub Render(ByVal writer As...
|
by: Simon Verona |
last post by:
I would normally use code such as :
Dim Customer as new Customer
Dim t as new threading.thread(AddressOf Customer.DisplayCustomer)
Customer.CustomerId=MyCustomerId
t.start
Which would create...
|
by: Joe |
last post by:
Does anyone know the difference, in practical terms, between
Thread.Sleep (10000) and Thread.CurrentThread.Join (10000)??
The MSDN says that with Join, standard COM and SendMessage pumping...
|
by: Extremest |
last post by:
I am new to threading and trying to figure some things out. Are all
variables in a thread set to only that thread? Meaning if I create 2
instances of a class and then put each one in a different...
|
by: admin |
last post by:
ok This is my main. Pretty much it goes through each category and
starts up 4 worker threads that then ask for groups to gether from. My
problem is that when the thread gets done it keeps the...
|
by: Chrace |
last post by:
Hi all,
I have a problem with with Thread.Join( Timeout ) where the timeout never occurs.
I basically need to make a connection to an AS400 box which works fine. Once in a blue moon the AS400...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |