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

When app runs, window turns white!!???

This application has a for loop that calls a large function:
"foreach (string invoice in listBox2.Items)"

and causes the window to turn white and loose view of all control.
How can I keep this from happening?
Thanks,
Trint

Nov 16 '05 #1
6 1558
Hi Trinity,

Run this large function in a new thread.

--
Regards,
Peter Jausovec
(http://blog.jausovec.net)
"trint" <tr***********@gmail.com> je napisal v sporocilo
news:11**********************@f14g2000cwb.googlegr oups.com ...
This application has a for loop that calls a large function:
"foreach (string invoice in listBox2.Items)"

and causes the window to turn white and loose view of all control.
How can I keep this from happening?
Thanks,
Trint

Nov 16 '05 #2
Hi Trint,

If I understand your problem correctly the whiteness is caused by a busy
application not having the time to repaint the controls. To solve this
you could handle the foreach loop in a different thread, keeping the GUI
thread up to speed, or call Application.DoEvents() ever so often inside
your loop to handle any waiting events.

On 15 Mar 2005 06:05:05 -0800, trint <tr***********@gmail.com> wrote:
This application has a for loop that calls a large function:
"foreach (string invoice in listBox2.Items)"

and causes the window to turn white and loose view of all control.
How can I keep this from happening?
Thanks,
Trint


--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3
Thanks, I will try putting in a separate thread.
Trint

Nov 16 '05 #4
hi,

Just be aware that you should access the UI from the worker thread.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"trint" <tr***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Thanks, I will try putting in a separate thread.
Trint

Nov 16 '05 #5
<"Ignacio Machin \( .NET/ C# MVP \)" <ignacio.machin AT
dot.state.fl.us>> wrote:
Just be aware that you should access the UI from the worker thread.


Just to correct Ignacio's typo:

Just be aware that you should *not* access the UI from the worker
thread.

See http://www.pobox.com/~skeet/csharp/winforms.shtml for more
information.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6
As others have pointed out, using a separate worker thread will free up
your main UI thread and your application will become responsive.

I have found the following article by Jason Clark to be helpful in
Windows Forms:

http://msdn.microsoft.com/msdnmag/issues/04/01/NET/

He shows how to use ThreadPool class in a WinForm.

-----------
Ajay Kalra
aj*******@yahoo.com

Nov 16 '05 #7

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

Similar topics

1
by: Vetrivel | last post by:
Application architecture : Develop interface between two existing systems, a. Enterprise CRM system b. Web based intranet system. Environment : Intranet Server : IIS and ASP. Script :...
3
by: spencer | last post by:
Hello, I have an index page with an autoscroller writen with CSS. The problem is the scrolling content(text and inages)'s position is correct but will off position when the broswer(IE) window...
10
by: Tom Szabo | last post by:
Is there an event when that triggers when the window is closing.... I am talking about when the user clicks on the cross on the right top corner of the window!!!
0
by: Heelios | last post by:
Hi, Is there any way to get when any window is maximized even if they are not part of the application ? For example : if the Outlook Express window is maximized i need to get its handle. ...
1
by: Gary | last post by:
Is it possible to refresh a browser window when a secondary browser window has been closed? For example, I have a main web form that functions purely as a datagrid, when a user clicks on a...
4
by: ken | last post by:
Hi, I have an activex calendar control. On the open event of the form I have the form go to a new record. The form opens with the calendar control blank. As soon as I enter a value anywhere on the...
1
by: zEE | last post by:
How to close all the child windows when parent window get closed? in ASP.net application through scripting..
21
by: alistair_henderson | last post by:
Morning All, I have some code for a website which uses 'window.open' to simulate modal dialog boxes. I use the window.closed property to decide if the window object exists at various points. ...
2
by: vidhyapriya | last post by:
is it possible to deactivate parent window form when child window form active if so,can u give some idea or coding about this....i m using vb.net window appln
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
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?
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
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...
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...

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.