Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. VB Multithreading

VB Multithreading

Scheduled Pinned Locked Moved Visual Basic
performancehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AG
    wrote on last edited by
    #1

    Hello, I am trying to run a multithread sort of application. But the compiled code is giving problems. In gives memory access violation. Pl. help. In .frm file--> Option Explicit Const CTF_COINIT = &H8 Const CTF_INSIST = &H1 Const CTF_PROCESS_REF = &H4 Const CTF_THREAD_REF = &H2 Private Declare Function SHCreateThread Lib "shlwapi.dll" (ByVal pfnThreadProc As Long, pData As Any, ByVal dwFlags As Long, ByVal pfnCallback As Long) As Long Private Sub Command1_Click() Dim i As Long SHCreateThread AddressOf NewThread, ByVal 0&, CTF_INSIST, ByVal 0& ' SHCreateThread AddressOf NewThread1, ByVal 0&, CTF_INSIST, ByVal 0& ' For i = 1 To 10000 ' Me.Caption = i ' Next End Sub in .bas file--> Option Explicit Sub NewThread() MsgBox "Messagebox, called from thread!" End Sub 'Sub NewThread1() ' MsgBox "Messagebox, called from thread ONE!" 'End Sub Regards, ~A.

    K 1 Reply Last reply
    0
    • A AG

      Hello, I am trying to run a multithread sort of application. But the compiled code is giving problems. In gives memory access violation. Pl. help. In .frm file--> Option Explicit Const CTF_COINIT = &H8 Const CTF_INSIST = &H1 Const CTF_PROCESS_REF = &H4 Const CTF_THREAD_REF = &H2 Private Declare Function SHCreateThread Lib "shlwapi.dll" (ByVal pfnThreadProc As Long, pData As Any, ByVal dwFlags As Long, ByVal pfnCallback As Long) As Long Private Sub Command1_Click() Dim i As Long SHCreateThread AddressOf NewThread, ByVal 0&, CTF_INSIST, ByVal 0& ' SHCreateThread AddressOf NewThread1, ByVal 0&, CTF_INSIST, ByVal 0& ' For i = 1 To 10000 ' Me.Caption = i ' Next End Sub in .bas file--> Option Explicit Sub NewThread() MsgBox "Messagebox, called from thread!" End Sub 'Sub NewThread1() ' MsgBox "Messagebox, called from thread ONE!" 'End Sub Regards, ~A.

      K Offline
      K Offline
      Klaus Probst
      wrote on last edited by
      #2

      Your code has so many problems I can't even begin to list them. Go here: www.powervb.com and buy the book. That's the only correct way to do threads in VB, period. Anything else is a hack, even if it seems to kinda work. ___________ Klaus [www.vbbox.com]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups