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

Windows form's refresh method does notwork

My windows form "Form1" has one Button "button1" and one TextBox "textBox1".
When I click button1, it do a job for each file in a directory. The job
include some platform invoke call. Before processing a file, I set
textBox1's Text property as filename of the file processed, and call
this->refresh() to refresh the form.

Every thing seems OK.
But, if the process time for some file is a little long (say 10 seconds) and
during processing I click at the form, the cursor becomes Cursors.Wait .
After that, the textBox1 stop refresh the filename untill all the jobs are
done.
All the jos are well done except stop refreshing.

How to fix it. Thanks

AJang
Jun 20 '06 #1
2 3689
I have seen similar behavior when updating text boxes in a loop which
is within a button handler. The processing continues, but the form
stops refreshing, a side affect is that my processing will complete
much faster since the GUI seems to not be repainted or updated
repeatedly. My guess is that an event that involves user interaction
interupts the processing of events, so that the form can finish
handling the current event. So your Click event causes the Wait cursor
so that the user knows that their interactions cannot be processed.

Possible things to try: Set the cursor to Wait yourself before you
begin processing files, so that at the least the user will hopefully
not try to click. I believe the events still fire however. You could
possible also set the entire form to Enabled = false to prevent event
handling. I'm not sure if the refreshing will still occur though.
Then at the end of processing you set the cursor back and enable the
form again.
This is similar to something I read about MouseMove, your MouseMove
event can fire only as fast as you can complete processing the event.
In other words, if your mousemove event handler is currently
processing, and another mousemove event is recieved, the event is not
queued, but instead discarded since processing cannot begin on it.

AJang wrote:
My windows form "Form1" has one Button "button1" and one TextBox "textBox1".
When I click button1, it do a job for each file in a directory. The job
include some platform invoke call. Before processing a file, I set
textBox1's Text property as filename of the file processed, and call
this->refresh() to refresh the form.

Every thing seems OK.
But, if the process time for some file is a little long (say 10 seconds) and
during processing I click at the form, the cursor becomes Cursors.Wait .
After that, the textBox1 stop refresh the filename untill all the jobs are
done.
All the jos are well done except stop refreshing.

How to fix it. Thanks

AJang


Jun 20 '06 #2
You could try moving the work onto a background thread? This would leave the
UI available for painting; you would, of course, need to sync the access to
the UI (since the background thread can't talk directly to the controls).

Marc
Jun 20 '06 #3

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

Similar topics

9
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text field called . It gets populated based on what the user selects in a field on the...
1
by: G Uljee | last post by:
Hi all, I've some difficulties with the screen/form locations. When I fist set my location of the form and then the execute the show command the form is located at...
1
by: Robert Clark | last post by:
This a pocket pc/smartphone questions mainly, but i thought i'd ask the question in the C# newsgroup. I have a form which i use to display information from a web service. From this form i open...
2
by: Peter Oliphant | last post by:
I now have graphics being drawn in the Paint event of my form (yeah, and it's very cool). Problem was that it only updated any changes to these graphics when Paint was called. So, I then made it...
5
by: Tmajarov | last post by:
Haven't been able to find a clear answer to this... I am building an asp.net application and trying to enforce some work flow by displaying a form via the showmodaldialog method. I can get the...
22
by: Br | last post by:
First issue: When using ADPs you no longer have the ability to issue a me.refresh to save the current record on a form (the me.refresh does a requery in an ADP). We usually do this before...
3
by: Ben | last post by:
Hi We have a windows form that takes a while to run a routine. During this we have created a information label, updating the user on the progress but: a) The changes on the label are not...
1
by: romerve | last post by:
Hello; i am having some problems trying to get a form that has a datagridview to refresh after a new record is created. I have a MDI container and menu form and add new record form; the menu...
1
by: sap0321 | last post by:
This should be kindergarten stuff but for some reason I am having trouble with it. I do 99.9% web programming and this is the first windows app i've done in years - probably the first ever in C# ......
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: 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: 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
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
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...

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.