473,395 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Thread Loading Form

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 ?
Nov 19 '07 #1
1 5555
You have this set up a bit backward. You're creating the a UI element
(the loading form) on a separate thread and doing the work on your UI
thread. Also, you could make things a bit easier on yourself by using
the BackgroundWorker class.

http://msdn2.microsoft.com/en-us/lib...undworker.aspx

On Nov 19, 9:07 am, Franck <the_darkbl...@hotmail.comwrote:
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 ?
Nov 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: D Witherspoon | last post by:
My application takes 5 or 6 seconds to load because of the time required to communicate with web services and load from the database. In the meantime I'd like to show a splash screen in a seperate...
13
by: Jason Jacob | last post by:
To all, I have a GUI program (use c#), and I have create a Thread for loading some bulk data, I also arrange the GUI program like this: 1) load a form showing "Wait for loading..." etc 2) a...
2
by: BG | last post by:
We're having trouble writing the code to update a UI control (label.Text) from a secondary thread. We're using C# with Windows Forms. We have a main form named MainForm, a splash screen form...
8
by: PAPutzback | last post by:
How do I keep the form up.
5
by: Roman | last post by:
Hello i have main mdi parent window from which i want to load a form, but during creating form object and later calling its Show method i want to display progress and have the main window...
3
by: John Wright | last post by:
I have a background worker thread that scans the network listing computers that are connected. I have a delegate that I call that invokes a procdure that loads a dataset with computer names and...
9
by: RvGrah | last post by:
I'm completely new to using background threading, though I have downloaded and run through several samples and understood how they worked. My question is: I have an app whose primary form...
4
by: DaTurk | last post by:
Hi, I have this windows app that I'm working on. When it loads it instantiates this object which creates a thread to read data and send it to the form. My problem is, is that I want to keep...
10
by: Paul E Collins | last post by:
I want to fill an ImageList with bitmaps for a ListView from another thread, because it's a time-consuming process. I expect the ListViewItems' images to "load" one by one, as in a Web browser. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.