VB threads

Posted on 2009-04-15
Medium Priority
Last Modified: 2012-05-06
I have threads running and one of them needs to spawn a standalone process/thread that will do independent processing.  I need this to run in background.  I also need it to be spawned again while the first is still running.  I just barely know about threads.  In an attempt to do this I used the code below.  All of it is in the same class.

It is not reentrant.
Public pro_train As Thread
    Public Processing As New Process_Train
   pro_train = New Thread(AddressOf Me.ProcessTheTrain)
   pro_train.Priority = ThreadPriority.Lowest
    Sub ProcessTheTrain()
    End Sub

Open in new window

Question by:fsoucy
  • 2
  • 2

Expert Comment

ID: 24150394
The code looks like you have the right idea.  What problems are you having?
This link is certainly worth a read:
If you plan on writing lots of concurrent programs, you may want to pick up Joe Duffy's "Concurrent programming on Windows" book.
Also, you probably want to add this to the VB zone.

Author Comment

ID: 24158421
The standalone thread is not relinquishing the CPU enough to allow other threads to operate in near real time.  The real time threads are set to a priority of High.

I tried to remidy this by adding DoEvents in places where there was loops with a large amount of iteration.  All that did was slow the background process.

Accepted Solution

obrienslalom earned 1500 total points
ID: 24164130
The 'real time' threads you are referring to are for the GUI?

When you spawn off the new thread, it will not discriminate between the two threads.  If you are seeing the application hang, something else might be going on.  Try not to use DoEvents until you know the messages are stuck in the message queue.

Author Comment

ID: 24167588
The real time threads are for data capture through high speed serial ports.

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question