473,399 Members | 4,177 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,399 software developers and data experts.

What is the best way to do this...

Hi
1. app start
2. user clicks Login Button
3. Application connects to the serwer ( check login and download dir list -
1mb )
Problem is when application is executing method responsible for dooing 3.
It takes time and i dont want my app to be "lagged".
I tought that i can create thread for this task. When thread will finish the
only thing that remains is to fill treewiev in main thread ( so i need to
invoke one method ).
is this good solution?
Sep 20 '06 #1
6 1099
Hello PiotrKolodziej,

This is reasonable solution, because main thread is not that place where
task shoul be run

In you main window you can show the progress bar informing your user how
long is remained to download

PHi
P1. app start
P2. user clicks Login Button
P3. Application connects to the serwer ( check login and download dir
Plist -
P1mb )
PProblem is when application is executing method responsible for
Pdooing 3.
PIt takes time and i dont want my app to be "lagged".
PI tought that i can create thread for this task. When thread will
Pfinish the
Ponly thing that remains is to fill treewiev in main thread ( so i
Pneed to
Pinvoke one method ).
Pis this good solution?
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Sep 20 '06 #2
PiotrKolodziej,

Well, it's your only solution really. How come it takes so long to
download the directory list?

But generally, yes, you should invoke another thread to do this and then
notify your main app when it is complete.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"PiotrKolodziej" <pi*************@gmail.comwrote in message
news:5a***************************@news.chello.pl. ..
Hi
1. app start
2. user clicks Login Button
3. Application connects to the serwer ( check login and download dir
list - 1mb )
Problem is when application is executing method responsible for dooing 3.
It takes time and i dont want my app to be "lagged".
I tought that i can create thread for this task. When thread will finish
the only thing that remains is to fill treewiev in main thread ( so i need
to invoke one method ).
is this good solution?

Sep 20 '06 #3
Thank you both.
I also need progress bar because of long time that is takes.
I tought i can call thread. Inside this thread create instance of
ProgressBarForm to display progress.
When login and download will complete i will dispose this form and Invoke
another method to let Main thread know that job is done.

Iam writing this because i have still in my mind other solution. Instead of
calling thread i can explicitly create instance of another Form ( with
progress bar and download methods ) and let the Main form know from new this
new Form if the job is done.

I'd like to know your opinion.
PK
Sep 20 '06 #4

PiotrKolodziej wrote:
Thank you both.
I also need progress bar because of long time that is takes.
I tought i can call thread. Inside this thread create instance of
ProgressBarForm to display progress.
When login and download will complete i will dispose this form and Invoke
another method to let Main thread know that job is done.

Iam writing this because i have still in my mind other solution. Instead of
calling thread i can explicitly create instance of another Form ( with
progress bar and download methods ) and let the Main form know from new this
new Form if the job is done.
Simply creating a second form will not make a difference if the
download is still happening on the UI thread. If the UI thread is
waiting for the download, it cannot be redrawing anything on the
screen, so your application will freeze.

No matter how you slice it, you need a background thread if you want
your application to remain responsive (and that includes drawing a
progress bar).

Sep 20 '06 #5
>
Simply creating a second form will not make a difference if the
download is still happening on the UI thread. If the UI thread is
waiting for the download, it cannot be redrawing anything on the
screen, so your application will freeze.

No matter how you slice it, you need a background thread if you want
your application to remain responsive (and that includes drawing a
progress bar).
I didn't mention that i will wait for the Second form to complete. I might
simply Show() not ShowDialog(), and let the Main thread go...
Sep 21 '06 #6

PiotrKolodziej wrote:

Simply creating a second form will not make a difference if the
download is still happening on the UI thread. If the UI thread is
waiting for the download, it cannot be redrawing anything on the
screen, so your application will freeze.

No matter how you slice it, you need a background thread if you want
your application to remain responsive (and that includes drawing a
progress bar).

I didn't mention that i will wait for the Second form to complete. I might
simply Show() not ShowDialog(), and let the Main thread go...
I doesn't matter whether you use Show() or ShowDialog(). The two forms
are both running on the UI thread. If you do the download from any form
you will block the entire UI.

Sep 21 '06 #7

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

Similar topics

23
by: darwinist | last post by:
What PHP Represents There is no shortage of complaints one could make about php as a language, and although the list does shrink with each release, some of them are inherent to the origins and...
226
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
145
by: Mark Johnson | last post by:
Oddly enough, I found it difficult, using Google, to find a list of best-of sites based on the quality of their css packages. So I'd ask. Does anyone know of particularly good sites which are in...
6
by: Mark Broadbent | last post by:
this might sound like an obvious question but I have found that usually these two evolve at the same time. One of the biggest reasons for creating the abstraction in the first place (in my...
5
by: l.woods | last post by:
I want your recommendation on which ASP.NET Shopping Cart software I should buy? Best code Best documentation Best support (if needed. I will buying source code, if possible) TIA, Larry...
6
by: jhooper71 | last post by:
It's been recommended to me to use a webservice and XML for the data manipulation layer for web applications in .NET 1.1. I was thinking I could use the web service to extend the database...
4
by: Ron Brennan | last post by:
Good evening, Windows 2000, JDK 1.5. What opinions do people have on what way and tool programmaticly produces the best quality thumbnails from larger images? On the web I've seen Java...
98
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
19
by: jsanshef | last post by:
Hi, after a couple of days of script debugging, I kind of found that some assumptions I was doing about the memory complexity of my classes are not true. I decided to do a simple script to...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.