Solved

VB threads

Posted on 2009-04-15
4
204 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
  • 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET 5 Templates 2 78
Webform example, External Authentication Services, OAUTH, asp.net 4.6.2 1 32
Windows Media Player 2 26
C# bracket error 3 31
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

773 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