Thread Loading Form

F

Franck

I have a form with a loading bar as marquee so i don't need to play
with the progress thing. It's just a form to show activity in other
way.

So what i need to do is start it at the beginning of the process which
take 10-30 sec depends and have to stop it at the end. I have to use
thread so i can see activity. I just have a little problem. when i
call my thread i see the form appearing and disappearing real fast
(like a quarter second). i havent been able to identify exactly the
problem but i think is because when thread reach end of his function
it stop by itself. I can understand that it;s logic. so here what i
use so far.

//Main declaration

Private frmModelSelectionLoadingBar LoadingBar;

//the function the thread trigger, i found that the form
//need to be instanciate in the thread or else it doesn't work

private void StartLoadingbar()
{
LoadingBar = new frmModelSelectionLoadingBar();
LoadingBar.Show();
}

//before i start running my code

Thread t = new Thread(new ThreadStart(StartLoadingbar));
t.Start();

// when it get under this line the form already disappear and
// at the end of my long code i put:

t.Suspend();

this give me error, so that's why i think when he run the function
StartLoadingBar
and finish it stop the thread automatically. So is what i found out is
right ? and
how could i fix this, i tought of a loop in the function but this is
going to slow down. Maybe a wait loop but how to make this and sheck
for a bool variable that i would change. i don't know, there must be a
better wait of coding that ?
 

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

Top