Introduction
Hi friends,
This is my first article on Code-Project on the topic Multithreading in VB.NET.
Multithreading is a technique, by which you can increase efficiency of your program by 100%. Every body wants to apply multi threading in their own application. But for beginner it's a bit difficult to apply multi threading properly. I had the same problem, when I was going to use it in my application. That's why I am writing this article, that beginner can easily apply multi threading in their application. I am trying to make it as simple as possible.
I am not writing this article against some ones request. Rather than, I am writing this article, as I personally faced a big problem on this topic. It was so hard to find out a good solution or help on "How to apply threading on application".
After so much study, search on google and on other forums at last I was able to apply multi threading in my application.
Multi Threading is not a critical or complex thing to do. But many people don't now how to apply it. They can get sample code, but can't implement it on their own project. Or they face trouble, when they try to apply the code in their application.
I am not writing much code here. Because, if you download the source code, provided with this article, you will find comment through out each line of coding. So I am not repeating them again here
The heart of this project is the following line of coding
Imports System.Threading
Dim objThreadClass As New clsThread(2, Me)
Dim objNewThread As New Thread(AddressOf objThreadClass.StartThread)
objNewThread.IsBackground = True
objNewThread.Start()
m_ThreadList.Item(1) = objNewThread
Public Sub ReceiveThreadMessage(ByVal ThreadIndex As Integer, _
ByVal Counter As Integer)
End Sub
Private Delegate Sub NotifyMainWindow(ByVal ThreadIndex As Integer, _
ByVal Counter As Integer)
Private m_NotifyMainWindow As NotifyMainWindow
m_NotifyMainWindow = AddressOf MainWindow.ReceiveThreadMessage
ReDim m_Args(1)
m_Args(0) = m_ThreadIndex
m_Args(1) = m_Counter
m_MainWindow.Invoke(m_NotifyMainWindow, m_Args)
If this helps you, I'll be so happy