Structure as parameter to thread in VB 2005

sukhvinder

New member
Joined
Aug 19, 2011
Messages
4
Programming Experience
1-3
Can any one show me how to type cast a structure , when passed as thread parameter

Thanks
 
structures as thred parameter

Can you please give or point me to an example....i am new to threads in VB
(Also i tried CType but it did not work...)....an example would help me understand the syntax

Thanks
 
Can you please give or point me to an example....i am new to threads in VB
(Also i tried CType but it did not work...)....an example would help me understand the syntax

Thanks
This has really nothing to do with threads. A cast is a cast and you cast in VB using DirectCast. As for examples, there is a whole WWW out there and I'm sure that, if you were to look, you'd find plenty of examples. Simply typing directcast into Google should produce loads. If you have tried and failed then you should show us what you did because, without that, we can't tell you what you did wrong.
 
Hi...here is my code

Private Structure Mystruct
Dim Member1 As Enum1
Dim Member2 As Integer
Dim Member3 As Enum2
Dim Member4 As Boolean
End Structure

Dim variable1 As Mystruct
Dim variable2 As Mystruct

Function
.....
m_thrd1 = New Thread(New ParameterizedThreadStart(AddressOf Mythread))
m_thrd1 .Start(variable1 )
.......

End Function

Private Sub Mythread(ByVal paramaters As Object)

localparameters as Mystruct

localparameters = CType(paramaters , Mystruct) .........
....
....
End Sub



Thanks
 
it compiles fine, but i get error at run time (i cannot debug this code at run time so i am using message boxes in my application).

Private Sub Mythread(ByVal paramaters As Object)
Messagebox.show("Inside Mythread") .........................i see this popup box but not the next one...
localparameters as Mystruct

localparameters = CType(paramaters , Mystruct) .........

Messagebox.show("localparameters = " + localparameters ) .... i do not see this message box
....
....
End Sub

i do not see any error or exception message...my code simply crashes
 
If there's a crash then there's an error message. A crash is an unhandled exception and every exception has an error message. When the crash occurs the IDE displays the Exception Assistant window and it provides you with lots of information, including the type of exception, the error message and more. All you have to do is read the information presented to you an relay it to us.
 
Back
Top