Multithreading Advice needed for VB.NET Application

V

Viet

I don't know if this is the right forum for my question but here goes: I am
converting a VB6 app to VB.NET and I would like to use Threads and
Threadpools. This main app (1) executes two other sub apps: app 2 and app 3.
In app 2, the original vb6 program utilized the form timers to execute 4
main routines in which one of these routines would constantly poll a Canon
scanner for the user to scan in documents. I recoded app2 so that it would
use the thread timer. This thread timer then executes a Threadpool Routine
that executes 4 Threadpools. Is this the most efficient way to do this to
make the program more responsive????

Thanks,
Jonathan

Code:


Sub Form1_Load(...)

Me. StartTimer()

End Sub 'Form1_Load

Public Sub StartTimer
' Create the delegate that invoke the method for the timer.
Dim timerDelegate As TimerCallback = AddressOf Me.StartSystemTimer

Dim stateTimer As System.Threading.Timer = New
System.Threading.Timer(timerDelegate, evt, TimeSpan.FromSeconds(3),
TimeSpan.FromSeconds(5))

End Sub 'StartTimer


Below is the MainThreadPool Routine that I implemented to execute the 4
routines as threadpools.

Public Sub MainThreadPoolRoutine()

'Create a pool of the 4 idle threads

'Start the first Thread to initialize the scanner and scan the documents

'lblMediatorStatusMsg.Text = "Executing 1st Threadpool - StartScan_Thread1"

ShowProgressBar(100)

ThreadPool.QueueUserWorkItem(AddressOf Startscan_Thread1, evt)

Refresh_Thumbnails()

Application.DoEvents()

evt.Set()

'Execute the shell to the Program Mediator and display the message that Doc
No has been read

'lblMediatorStatusMsg.Text = "Executing 2nd Threadpool - FileCheck_Thread2"

ShowProgressBar(100)

ThreadPool.QueueUserWorkItem(AddressOf FileCheck_Thread2, evt)

Refresh_Thumbnails()

Application.DoEvents()

evt.Set()

'Display the check images (thumbnails) that are scanned

'lblMediatorStatusMsg.Text = "Executing 3rd Threadpool -
CheckChecks_Thread3"

ShowProgressBar(100)

ThreadPool.QueueUserWorkItem(AddressOf CheckChecks_Thread3, evt)

Refresh_Thumbnails()

Application.DoEvents()

evt.Set()

'Final processing and display thumbnails

'lblMediatorStatusMsg.Text = "Executing 4th Threadpool - DoneCheck_Thread4"

ShowProgressBar(100)

ThreadPool.QueueUserWorkItem(AddressOf DoneCheck_Thread4, evt)

Refresh_Thumbnails()

Application.DoEvents()

evt.Set()

'End the Program Mediator

'lblMediatorStatusMsg.Text = "Executing 5th Threadpool -
EndMediator_Thread5"

'ShowProgressBar(100)

'ThreadPool.QueueUserWorkItem(AddressOf EndMediator_Thread5, evt)

'Refresh_Thumbnails()

'Application.DoEvents()

'evt.Set()

End Sub 'MainThreadPoolRoutine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top