Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB threads

Posted on 2009-04-15
4
Medium Priority
?
212 Views
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
   pro_train.Start()
 
    Sub ProcessTheTrain()
            Processing.CCLPS_Main(OutputFileName)
 
    End Sub

Open in new window

0
Comment
Question by:fsoucy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:obrienslalom
ID: 24150394
The code looks like you have the right idea.  What problems are you having?
This link is certainly worth a read:
http://www.albahari.com/threading/
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.
0
 

Author Comment

by:fsoucy
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.
0
 
LVL 6

Accepted Solution

by:
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.
0
 

Author Comment

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

610 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