473,836 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Threading Question

I have code:

Dim th as new threading.threa d(addressof MyMethod)
th.start()
If th.threadstate = threadstate.run ning then
th.priority = threading.threa dpriority.above normal
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 3247
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.run ning.

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

Dim th as new threading.threa d(addressof MyMethod)
th.start()
If th.threadstate = threadstate.run ning then
th.priority = threading.threa dpriority.above normal
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.Uns tarted.

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.threa d(addressof MyMethod)
th.start()
If th.threadstate = threadstate.run ning then
th.priority = threading.threa dpriority.above normal
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********@nos pam.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********@nos pam.hotmail.com > wrote in message
news:eB******** ******@TK2MSFTN GP12.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.threa d(addressof MyMethod)
th.start()
If th.threadstate = threadstate.run ning then
th.priority = threading.threa dpriority.above normal
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
6774
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 language's 30+ year evolution. What to you think python largest compromises are? The three that come to my mind are significant whitespace, dynamic typing, and that it is interpreted - not compiled. These three put python under fire and cause...
19
6498
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. "somethread.interrupt()" will wake somethread up when it's in sleeping/waiting state. Is there any way of doing this with python's thread? I suppose thread interrupt is a very primitive functionality for stopping a blocked thread.
3
1500
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 killed when the import of the module is complete. Is this expected? Does python have to be in control to allow threads to run? Would it be better to arrange things such that the file is processed using PyRun_SimpleFile? David S. Harrison
4
1597
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 data-collecting piece of the code runs in a thread. 1. Open the db, and each thread writes the result immediately. (Sub-question: which is better: cursor object passed to the thread
6
555
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 and the final process(3) gets called. what am I doing wrong with the threading? by the way Directory.GetFiles(IncomingXMLPath1).Length is some global outcome from process 1. Thanks 1)
7
318
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, Anthony Nystrom
4
1310
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 process messages coming out of a thread? I want to queue them up, but MessageQueue doesn't look like what I need. Should I just make my own queue class? If so I'll have to worry about enumerator synchronization... a pointer to a 'best practice'...
4
321
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 this method, I iniate a PROCESS and on completion, it reduces the available worker thread and continue. I have couple of questions; 1. Since I am launching multiple threads on a same method, do I have to take care of locking so that each one...
4
1607
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 threading. The instructor is of the opinion that threading is not very useful and glossed over the subject. At least he admitted that he was glossing it over. I've noticed that many of the postings on this board have to do with threading and I...
19
1813
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. Threading is a new concept for me to implement. Here is my problem. I have a system that receives xml files and records their file locations in a database. I can potentially receive thousands,
0
9825
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9671
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10852
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10553
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10255
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9382
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6980
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5829
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.