473,395 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Multithreading Advice needed for VB.NET Application

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
Nov 21 '05 #1
1 1734
Hello?? Any assistance??
"Viet" <vp**@starcalif.com> wrote in message
news:#F**************@TK2MSFTNGP10.phx.gbl...
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

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

47
by: mihai | last post by:
What does the standard say about those two? Is any assurance that the use of STL is thread safe? Have a nice day, Mihai.
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
16
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
16
by: who be dat? | last post by:
Consider the following code which enables multithreading in an ASP.Net application I'm writing: Code in global.asx Application_start subroutine, Threadnotify is declared Globally as a new thread...
2
by: shonend | last post by:
**** sorry about the length of the message. If you can't read the whole thing and still willing to help, read the last 2 paragraphs where the main problem is described. The introduction story is...
4
by: Boni | last post by:
Dear all, Is there some trick to put controls on a particular control but in other thread. Example: A control is a part of bigger application and application thread freezes somtimes. So a...
28
by: JV | last post by:
My ASP.NET application needs to accept data from a post and return quickly. I've added a worker thread to wake up and save data asynchronously after the data is received. But, it appears to me...
7
by: Ray | last post by:
Hello, Greetings! I'm looking for a solid C++ multithreading book. Can you recommend one? I don't think I've seen a multithreading C++ book that everybody thinks is good (like Effective C++ or...
0
by: srikmr | last post by:
I have a scenario which needs some expert advice from people who worked on multithreading in C#. Here is the scenario: I have an Application (Let’s name it as MyApplication) which is invoked by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.