Thread just wont start!!?!?!

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

Hi there,

This one is really doing my head in, I am attempting to start a thread
using the following code,

--------------------

Public Sub start()
cTrdImportThread = New Threading.Thread(AddressOf
cTrdImportThread_Callback)
With cTrdImportThread
.Name = Tiger_AssemblyInfo.assemblyRootNamespace &
".PowerPointImporter"
.IsBackground = False
End With
Try
Call cTrdImportThread.Start()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
MessageBox.Show("Thread started!, state = " &
cTrdImportThread.ThreadState.ToString & ".")
End Sub

Private Sub cTrdImportThread_Callback()
MessageBox.Show("Hello??")
End Sub

--------------------

Even though no exception is raised when calling "Start" the thread never
starts, the message box at the end of the start routine states that the
thread is unstarted. It's as if the object does nothing what so ever. Any
ideas on why this is happening?? It has only started happening recently but
I'm unsure as to why.

Thanks loads for your help in advance!!
 
Nick,

We have a long time not seen, I see this when there are licence problems,
than I start searching for your name. With Nick Paterman there are not much
only with that other nick.

I find this so nice writing. "Nick has now changed his nick in Nick", The
previous was more distinct.

However I have pasted your code (slightly changed because I don't have that
class that you use) in a form

I get two messageboxes showed each over each other, so the problem is in my
idea not in this code part.

\\\
Private Sub cTrdImportThread_Callback()
MessageBox.Show("Hello??")
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim cTrdImportThread As New Threading.Thread(AddressOf
cTrdImportThread_Callback)
With cTrdImportThread
.Name = "whatever"
.IsBackground = False
End With
Try
Call cTrdImportThread.Start()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
MessageBox.Show("Thread started!, state = " &
cTrdImportThread.ThreadState.ToString & ".")
End Sub

I hope it helps something

Cor
 
Hi Cor,
We have a long time not seen, I see this when there are licence problems,
than I start searching for your name. With Nick Paterman there are not
much only with that other nick.

I find this so nice writing. "Nick has now changed his nick in Nick", The
previous was more distinct.

Yeah I thought it best to change my name from Nak to Nick, just incase
someone decides to accuse me of concealing my identity again, not that I
have any need to of course. :-)
\\\
Private Sub cTrdImportThread_Callback()
MessageBox.Show("Hello??")
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim cTrdImportThread As New Threading.Thread(AddressOf
cTrdImportThread_Callback)
With cTrdImportThread
.Name = "whatever"
.IsBackground = False
End With
Try
Call cTrdImportThread.Start()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
MessageBox.Show("Thread started!, state = " &
cTrdImportThread.ThreadState.ToString & ".")
End Sub

That's has produced to stranges results ever, from changing the name
from something that previously worked to something to "whatever" causes the
thread to start in about 10 seconds after start is called!! The application
is at rest when start is called so I'm really confused as to what is
actually happening there. But the good thing is that it is actually doing
something now! :-D

Thanks loads for your help, looks like i'm going to have to search a
little deeper into this problem :-\

Nick.
 
Actually just to add another element of confusion to that, on another system
the thread never starts! woooooooooo.....
 
Well I've found the problem now and it was completely unrelated to the
treading code. I was using incorrect versions of some primary interop DLL's
which were either not loading at all or taking ages to load! Though one
thing I am unsure of is why the DLL was being loaded when the thread was
being started as opposed to when the class was initialized. Anyway, a
problem sorted none the less :-)

Nick.
 
Nick,

Are you sure you want to set that IsBackGround to false, I assume that you
want True

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top