displaying data realtime in a textbox

A

auldh

hello,
i'm not sure if this is possible. i have a small VS 2005 C# windows
application. it has a textbox and a button. once the user presses the button
it fires off many tasks. i want to use the "textbox" to give realtime update,
a status window.

it seems that in some part of the program the window form goes blank and
there is no status. however once the program stops i get my textbox/status
updates.

so the question is, can i get the textbox to give realtime update? i tried
the textbox.refresh() and nothing. i get no status/updates until the program
stops running.
 
P

Paul E Collins

auldh said:
i want to use the "textbox" to give realtime update
[...]
it seems that in some part of the program the window form goes blank
and there is no status.

If you do long-running tasks on the main (GUI) thread, the window can't
update properly. Use the BackgroundWorker control, or create a separate
thread to do the long-running task.

Eq.
 
A

auldh

thanks Paul, i will research this.

Paul E Collins said:
auldh said:
i want to use the "textbox" to give realtime update
[...]
it seems that in some part of the program the window form goes blank
and there is no status.

If you do long-running tasks on the main (GUI) thread, the window can't
update properly. Use the BackgroundWorker control, or create a separate
thread to do the long-running task.

Eq.
 
J

JamesB

Paul E Collins said:
auldh said:
i want to use the "textbox" to give realtime update
[...]
it seems that in some part of the program the window form goes blank and
there is no status.

If you do long-running tasks on the main (GUI) thread, the window can't
update properly. Use the BackgroundWorker control, or create a separate
thread to do the long-running task.

Auldh has the better answer, but for something quick and dirty, you might
want to put some "Application.DoEvents()" in at various points (i.e. where
you put in the Refresh()) - this will enable the UI to update.
 
P

Peter Duniho

Auldh has the better answer, but for something quick and dirty, you
might want to put some "Application.DoEvents()" in at various points
(i.e. where you put in the Refresh()) - this will enable the UI to
update.

Please do not recommend Application.DoEvents() when there are other,
superior alternatives available. It's not something to be used in a
well-written program and is not appropriate as a recommendation.

If you observe a situation where the _only_ way to solve the problem is
calling DoEvents(), by all means suggest it. Otherwise, you're only
encouraging sloppy programming practices and that's not something that any
responsible person should want to do.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top