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 2118
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: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
| |