473,395 Members | 1,797 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.

How to initialize application in a different thread?

Hi,

My application need to do some initialization before it can be used
I want to display a form with the status of initialization for example:

"connection to data base..."
"loading settings....."
"registering user..."

etc...

I am thinking about using Thread.QueueUserWorkItem
to run each method
and in the end of each Thread function to Queue the next method
is this a right way?

thanks.

Nov 16 '05 #1
6 3633
I'd spawn another thread (by creating a Thread instance and calling Start). Then have the thread report its progress via Form.BeginInvoke

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<u#**************@TK2MSFTNGP11.phx.gbl>

Hi,

My application need to do some initialization before it can be used
I want to display a form with the status of initialization for example:

"connection to data base..."
"loading settings....."
"registering user..."

etc...

I am thinking about using Thread.QueueUserWorkItem
to run each method
and in the end of each Thread function to Queue the next method
is this a right way?

thanks.


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004

[microsoft.public.dotnet.languages.csharp]
Nov 16 '05 #2
If you mean this will be on a splash screen before the app starts, it's
probably reasonable to use the main thread since you can't do anything until
it finishes anyhow.

But - if you did want to make this multi-threaded, I'd have a class for the
initialization procedure and have it fire events at significant events.

"Julia" <co********@012.net.il> wrote in message
news:u%******************@TK2MSFTNGP11.phx.gbl...
Hi,

My application need to do some initialization before it can be used
I want to display a form with the status of initialization for example:

"connection to data base..."
"loading settings....."
"registering user..."

etc...

I am thinking about using Thread.QueueUserWorkItem
to run each method
and in the end of each Thread function to Queue the next method
is this a right way?

thanks.

Nov 16 '05 #3
Julia <co********@012.net.il> wrote:
My application need to do some initialization before it can be used
I want to display a form with the status of initialization for example:

"connection to data base..."
"loading settings....."
"registering user..."

etc...

I am thinking about using Thread.QueueUserWorkItem
to run each method
and in the end of each Thread function to Queue the next method
is this a right way?


Why use the thread pool? Just start a single separate thread to do all
the initialisation, reporting back to the UI with Control.Invoke to
give progress.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
Hi, Julia.
If all those tasks (connect database, load setting ...) have to run one
after another (as implied by the way you plan to run them through the thread
pool), there is really no need to put them into the thread pool. If you just
wanna keep the application's response time short when the initialization is
under way, may be you can just start a new thread to perform all those tasks
one by one.

Best Regards
Ming Chen

"Julia" <co********@012.net.il> wrote in message
news:u%******************@TK2MSFTNGP11.phx.gbl...
Hi,

My application need to do some initialization before it can be used
I want to display a form with the status of initialization for example:

"connection to data base..."
"loading settings....."
"registering user..."

etc...

I am thinking about using Thread.QueueUserWorkItem
to run each method
and in the end of each Thread function to Queue the next method
is this a right way?

thanks.

Nov 16 '05 #5
Hi,

I think that the others post have all the answer that you need, if you need
the code just drop me a line

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Julia" <co********@012.net.il> wrote in message
news:u%******************@TK2MSFTNGP11.phx.gbl...
Hi,

My application need to do some initialization before it can be used
I want to display a form with the status of initialization for example:

"connection to data base..."
"loading settings....."
"registering user..."

etc...

I am thinking about using Thread.QueueUserWorkItem
to run each method
and in the end of each Thread function to Queue the next method
is this a right way?

thanks.

Nov 16 '05 #6
Hi

You can put all the methods immediately by Thread.QueueUserWorkItem because
although there are max of 25 threads, all other methods will be put in the
queue and as soon as a thread is ready it will get the method from queue. You
can use an event which is signaled at the end of work of all threads,
informing the form that application can work now.
"Julia" wrote:
Hi,

My application need to do some initialization before it can be used
I want to display a form with the status of initialization for example:

"connection to data base..."
"loading settings....."
"registering user..."

etc...

I am thinking about using Thread.QueueUserWorkItem
to run each method
and in the end of each Thread function to Queue the next method
is this a right way?

thanks.

Nov 16 '05 #7

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

Similar topics

3
by: Amit Dedhia | last post by:
Hi I am developing a Dot net application (involving image processing) on a uni processor. It works well on my machine. I then take all my code on a multi processor, build and run the application...
8
by: bryan | last post by:
I'm using the UIP App block and I have overridden the Initialize method, but my override never gets called. Here's the code: public override void Initialize(TaskArgumentsHolder args,...
13
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow...
8
by: TrtnJohn | last post by:
I have an application where I would like to block waiting on an asynchronous event and still process messages. I can implement a hard loop to block such as: Do While StillWaiting...
1
by: philwozza | last post by:
Hi I have a THREAD class that uses the static variable NextThreadID to store the id of the next thread to be created and a static Mutex to protect it. class THREAD { public: int Start(void);...
22
by: silversurfer2025 | last post by:
Hello everybdy, I am a little confused for the following reason: In my code I used a simple for-loop in order to initialize a 2D-array of floats to zero. Because of efficiency reasons, I changed...
18
by: toton | last post by:
Hi, In C++ when I initialize an array it, also initializes the class that it contains, which calls the default constructor. However, I want to initialize the array only (i.e reserve the space) and...
7
by: Ashutosh Bhawasinka | last post by:
Hi, I have a C++ DLL, it exports some some plain C style functions. This functions internally initializes COM and then MAPI. This works fine if I use the DLL from a C++ application (I tested...
1
by: =?Utf-8?B?SmFzb24=?= | last post by:
Hi all, I have set up ODBC connection through data source configuration wizard and I can run my application normally. But without any changes of my application & ODBC connection, the error is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.