[Tutorial] Multi-Threading

Discussion in 'Programming General' started by pvash2, May 5, 2009.

[Tutorial] Multi-Threading
  1. Unread #1 - May 5, 2009 at 8:22 PM
  2. pvash2
    Joined:
    May 5, 2009
    Posts:
    23
    Referrals:
    0
    Sythe Gold:
    0

    pvash2 Newcomer

    [Tutorial] Multi-Threading

    I will be showing you how to use Multi-Threading,
    Why is this useful? Instead of having a linear flow of data, you can split up the work load into threads so while you have, for example a counter going, you can have progress be updated to a progress bar as that is happening.

    Start by opening up a blank project (NOTE: I am using Visual Basic 2008)

    Code:
    Imports System.Threading.Thread
    
    Private Class Test
       Dim TestThread As System.Threading.Thread 'Define the thread/thread name
    
       Private Sub Main_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
          Dim TestThread As New System.Threading.Thread(AddressOf TestSub) 'Address the sub which will contain code for our thread
          Control.CheckForIllegalCrossThreadCalls = False 'Allows you to make calls changes to windows form/other threads
          TestThread.Start() 'Initialize the thread
       End Sub
    
       Public Sub TestSub()
          'Code here
       End Sub
    End Class
    I discovered this after wondering why my Visual Basic application wasn't responding whenever i tried to execute a hefty amount of code, the multi-threading fixed it.
     
  3. Unread #2 - May 6, 2009 at 1:31 AM
  4. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    [Tutorial] Multi-Threading

    Try the .NET section ;)
     
< need counter-strike: source hack coder | Need help adding info from listboxes into combo boxes >

Users viewing this thread
1 guest


 
 
Adblock breaks this site