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