473,671 Members | 2,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 frmModelSelecti onLoadingBar 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 frmModelSelecti onLoadingBar();
LoadingBar.Show ();
}

//before i start running my code

Thread t = new Thread(new ThreadStart(Sta rtLoadingbar));
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 5567
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 BackgroundWorke r class.

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

On Nov 19, 9:07 am, Franck <the_darkbl...@ hotmail.comwrot e:
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 frmModelSelecti onLoadingBar 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 frmModelSelecti onLoadingBar();
LoadingBar.Show ();

}

//before i start running my code

Thread t = new Thread(new ThreadStart(Sta rtLoadingbar));
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
7900
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 thread. I am trying the following code and it shows the form for a split second and then dissapears. Can someone help me out with what I'm doing wrong here. Thanks, Dan
13
3620
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 Thread is then created to load the bulk data 3) after the thread has completed, close the "Wait for loading" form 4) show the main form for the GUI program
2
11781
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 named SplashScreen, and a C# class library named BackgroundProcess.
5
3214
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 responsive. But the problem is that i cannot load form from another thread, when i try to set its MdiParent property to main window, i get message that parent and child cant be on separate threads. I could invoke Show without setting MdiParent, but...
3
3184
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 then attaches it to a dropdown. When I run it, my UI freezes until it completes. Any thoughts on how to do this without freezing the UI? John Code
9
18020
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 will almost always lead to the user opening a certain child window that's fairly resource intensive to load. Is it possible to load this form in a backgroundworker and then use the Show method and hide method as necessary? Anyone know of
4
1174
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 this thread around for the lifetime of the object, reading and sending data to the from, but it seems to exit when the form completed loading. Why is it doing this? And is there a way I can keep it around after the form loads, without the form...
10
5050
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. I wrote the following code, but the form freezes up while CreateTileBitmaps is running, just as if I'd done it on the main thread. How can I add items to the ImageList without this problem? (Note: I do *not* want to use an owner-draw ListView and...
0
8474
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8912
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8597
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4403
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2049
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1807
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.