MultiThreading in VB.NET


VB.NET has a very great feature called MultiThreading (MT) which is not available in classic VB. In the past, MultiThreading is only available and limited within C++ programming language development environment. Now with this great feature becoming part of VB.NET, you should fully utilize this feature as it allows you to separate your applications into multiple parts (threads), each handling different tasks.


Advantages of MultiThreading

The main advantage of multithreading is that it allows your application to work on many tasks at the same time. Sometimes it is also known that the application runs faster with multithreading as the time for each of the tasks is divided by the CPU and executed concurrently, thus greatly minimizes idle CPU time.

Multithreading is mainly used in applications with lengthy processes which involves sophisticated calculations where the CPU is utilized intensively. Usually, this lengthy process is run on a separate thread from the graphical user interface as the user can still be able to work on this user interface while the lengthy process is running. Hence, the application will not look dead as the user interface is still responding to the user request.



What happens if there is no MultiThreading

Without multithreading where both the lengthy process and the user interface is running under the same thread, this is what will happen. As soon as the user clicks on the button in the user interface to start the lengthy process, the entire user interface freezes. After a while, a non-responding message for this process will occur in the title bar as well as in the task manager.
Although the application is actually still running and the not responding message might not be true entirely, the user has to wait until the lengthy process finishes before the user interface comes back to life again. This also prohibits the user from using a progressbar in the application as it will not work since the user interface is already freezed. The user might not know or will not have any hints on when the lengthy process will finish.


Click the link below to see how you can implement Multithreading into your project.

See MultiThreading VB.NET sample codes here

0 comments