Threading question - please help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

I hope someone could help me

I'm trying to prevent code from running before the thread I created completes. Here's the code snippet

DataTransformerWorker dtw = new DataTransformerWorker(strApplicationFolder, strSupplier
strFile, lblProgress, ProgressBar1)
//create new threa
ThreadStart tdStart = new ThreadStart(dtw.StartProcess)
Thread td = new Thread(tdStart)
td.Start()

*** I want to prevent the code below from running before the td thread complete

BindDataGridResults()
Cursor.Current = Cursors.Default
btnImport.Enabled = true

I don't know before hand how long the td thread lasts. Any suggestions

Thanks
Edward
 
What you could do is to call Thread.Join(). This will block your current
thread until the other thread exited (or an optional timeout expired).
In your example:
td.Join()

José
Edward said:
Hello,

I hope someone could help me.

I'm trying to prevent code from running before the thread I created
completes. Here's the code snippet:
DataTransformerWorker dtw = new
DataTransformerWorker(strApplicationFolder, strSupplier,
 

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