Solved

VB threads

Posted on 2009-04-15
4
207 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

707 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