Threading Question

I have a VB .NET windows application that I spawns a thread to send to a web service. The problem I'm having is that some of the values that the thread needs come from text and combo boxes. When I use threading sometimes the text values appear empty "" 
When I turn off the threading and do it the 'old-fasion' everything works great.

any ideas ?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I tend to wrap threads which need values in their own class... so something like this (it's a bit rushed):

Public Class ThreadWrapper
    Public myText As String
    Public myInt As Integer
    Private thisThread As Threading.Thread

    Public Sub New(ByVal NewText As String, ByVal NewInt As Integer)
        myText = NewText
        myInt = NewInt
    End Sub

    Public Sub Start()
        thisThread = New Threading.Thread(AddressOf threadStart)
    End Sub

    Private Sub threadStart()

        'your code here using the values myText and myInt

        RaiseEvent ThreadFinished(Me)
    End Sub

    Public Event ThreadFinished(ByVal sender As ThreadWrapper)
End Class


Then in your form somewhere...

Dim myThread as new ThreadWrapper(Combobox1.Text, 123)
AddHandler myThread.ThreadFinished, AddressOf MyThreadHandler

Then somewhere else in your form.. add the handler for the event finished  (it's not necessary but you'll probably want to capture when it's finished)

Sub MyThreadHandler(sender as ThreadWrapper)
      ' handle the event
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
thenrichAuthor Commented:
I'll give it a shot !!!
thenrichAuthor Commented:
Good coding form and good idea!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.