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. thread problem

thread problem

Scheduled Pinned Locked Moved Visual Basic
helpcsharpvisual-studiotutorial
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.
  • H Offline
    H Offline
    hassanasp
    wrote on last edited by
    #1

    'i made class in seperate file Imports System.Threading Class program Private Class MessageInfo Private iteration As Integer Private message As String Public Sub New(ByVal iteration As Integer, ByVal message As String) Me.iteration = iteration Me.message = message End Sub Public ReadOnly Property Iterations() As Integer Get Return iteration End Get End Property Public ReadOnly Property Messages() As String Get Return message End Get End Property End Class Public Shared Sub DisplayMessage(ByVal state As Object) Dim config As MessageInfo = TryCast(state, MessageInfo) If config Is Nothing Then Dim count As Integer For count = 0 To 2 Step count + 1 Console.WriteLine("a thread pool example") Thread.Sleep(1000) Next Else Dim count As Integer For count = 0 To config.Iterations - 1 Step -1 Console.WriteLine(config.Messages) Thread.Sleep(1000) Next End If End Sub End Class 'and try to use it in sub Main Imports System.Threading Module Module1 Sub Main() ThreadPool.QueueUserWorkItem(MessageInfo.DisplayMessage) Dim info As New MessageInfo(5, "a thread pool example with arguments") ThreadPool.QueueUserWorkItem(MessageInfo.DisplayMessage, info) Console.WriteLine("Main method complete. press enter") Console.ReadLine() End Sub End Module error Error 1,2,3 Type 'MessageInfo' is not defined. C:\Documents and Settings\Sokar\My Documents\Visual Studio 2005\Projects\ConsoleApplication16\ConsoleApplication16\Module1.vb 7 25 ConsoleApplication16

    Ahmed hassan

    D 1 Reply Last reply
    0
    • H hassanasp

      'i made class in seperate file Imports System.Threading Class program Private Class MessageInfo Private iteration As Integer Private message As String Public Sub New(ByVal iteration As Integer, ByVal message As String) Me.iteration = iteration Me.message = message End Sub Public ReadOnly Property Iterations() As Integer Get Return iteration End Get End Property Public ReadOnly Property Messages() As String Get Return message End Get End Property End Class Public Shared Sub DisplayMessage(ByVal state As Object) Dim config As MessageInfo = TryCast(state, MessageInfo) If config Is Nothing Then Dim count As Integer For count = 0 To 2 Step count + 1 Console.WriteLine("a thread pool example") Thread.Sleep(1000) Next Else Dim count As Integer For count = 0 To config.Iterations - 1 Step -1 Console.WriteLine(config.Messages) Thread.Sleep(1000) Next End If End Sub End Class 'and try to use it in sub Main Imports System.Threading Module Module1 Sub Main() ThreadPool.QueueUserWorkItem(MessageInfo.DisplayMessage) Dim info As New MessageInfo(5, "a thread pool example with arguments") ThreadPool.QueueUserWorkItem(MessageInfo.DisplayMessage, info) Console.WriteLine("Main method complete. press enter") Console.ReadLine() End Sub End Module error Error 1,2,3 Type 'MessageInfo' is not defined. C:\Documents and Settings\Sokar\My Documents\Visual Studio 2005\Projects\ConsoleApplication16\ConsoleApplication16\Module1.vb 7 25 ConsoleApplication16

      Ahmed hassan

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Dont post this a second time. Keep it in your original post thread. Also, this problem has nothing to do with threading.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008
      But no longer in 2009...

      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