473,320 Members | 2,094 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,320 software developers and data experts.

Threading Question

I have code:

Dim th as new threading.thread(addressof MyMethod)
th.start()
If th.threadstate = threadstate.running then
th.priority = threading.threadpriority.abovenormal
End If

My question is... wouldn't the thread always be running
and the if statement always fire off with setting the
priority?
Nov 20 '05 #1
7 3162
Hi IcedCrow,

Assuming that the thread has had enough time to finish starting [as it
were ;-)], that nothing went wrong, and also that it doesn't immediately send
itself to sleep, then yes, th.threadstate should be threadstate.running.

Regards,
Fergus
Nov 20 '05 #2
"IcedCrow" <ch********@aol.com> schrieb
I have code:

Dim th as new threading.thread(addressof MyMethod)
th.start()
If th.threadstate = threadstate.running then
th.priority = threading.threadpriority.abovenormal
End If

My question is... wouldn't the thread always be running
and the if statement always fire off with setting the
priority?


You ask because it doesn't? ;-) The thread does not start immediatelly. The
OS takes it into account when scheduling all threads, and it is started when
it is it's turn. Til it is started, it's state is ThreadState.Unstarted.

I read in the docs that the state is not Started before the Start method is
called. Well, that's right, but it doesn't change to Started _immediatelly_.
--
Armin

Nov 20 '05 #3
theoretically, I think it's possible that the thread could finish running
before th.threadstate's value is actually tested, especially if the main
thread lost it's time slice right after th.start(). Also, I'm not sure if
chaning priorities has much effect on a thread that has already been
started, but that's just conjecture....


"IcedCrow" <ch********@aol.com> wrote in message
news:1d****************************@phx.gbl...
I have code:

Dim th as new threading.thread(addressof MyMethod)
th.start()
If th.threadstate = threadstate.running then
th.priority = threading.threadpriority.abovenormal
End If

My question is... wouldn't the thread always be running
and the if statement always fire off with setting the
priority?

Nov 20 '05 #4
Hi Christine,

|| I'm not sure if changing priorities has much effect on a thread
|| that has already been started, but that's just conjecture....

It seems reasonable that you can. Task Manager allows this to be done on
the context menu of each process.

Regards,
Fergus
Nov 20 '05 #5
Hello,

"Christine Nguyen" <hc********@nospam.hotmail.com> schrieb:
Also, I'm not sure if chaning priorities has much effect on a thread
that has already been started, but that's just conjecture....


Should work.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #6
Hi IcedCrow,

I saw your query in the xml newsgroup and posted a message but it seems to
have joined the multitude in the void.

It was just to tell you that I've answered a query in this newsgroup about
namespaces. You might want to have a read.

Topic: using xml schema with xmlDOm in .net
Dated: 26th Sep, 2:03am
Sender: Yair Cohen

Regards,
Fergus

Nov 20 '05 #7
Thanks Fergus and Herfried.

"Christine Nguyen" <hc********@nospam.hotmail.com> wrote in message
news:eB**************@TK2MSFTNGP12.phx.gbl...
theoretically, I think it's possible that the thread could finish running
before th.threadstate's value is actually tested, especially if the main
thread lost it's time slice right after th.start(). Also, I'm not sure if
chaning priorities has much effect on a thread that has already been
started, but that's just conjecture....


"IcedCrow" <ch********@aol.com> wrote in message
news:1d****************************@phx.gbl...
I have code:

Dim th as new threading.thread(addressof MyMethod)
th.start()
If th.threadstate = threadstate.running then
th.priority = threading.threadpriority.abovenormal
End If

My question is... wouldn't the thread always be running
and the if statement always fire off with setting the
priority?


Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
19
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException....
3
by: David Harrison | last post by:
I am working on an application on Mac OS X that calls out to python via PyImport_ImportModule(). I find that if the imported module creates and starts a python thread, the thread seems to be...
4
by: Antal Rutz | last post by:
Hi, All! I'm new to threading. I have some design questions: Task: I collect data and store them in an RDBMS (mysql or pgsql) The question is how to do that with threading? The...
6
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service...
7
by: Anthony Nystrom | last post by:
What is the correct way to stop a thread? abort? sleep? Will it start up again... Just curious... If the thread is enabling a form, if the form is disposed is the thread as well? Thanks, ...
4
by: Bob | last post by:
- For cleanup, is it sufficient to set a Thread to Nothing after it's done? - It is OK to pass objects out of the thread? (dumb question maybe but I want to be sure) - What's the best way to...
4
by: DBC User | last post by:
I have a background process which reads a table to see if there are any pending requests. If there are any, then it will start a worker thread (only 10 allowed at a time) and executes a method. In...
4
by: Steven | last post by:
I am taking an "advanced" VB.Net course via web at a state university toward an information science degree. This is my second VB class and I am kind of disappointed in it. This week we covered...
19
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.