Yielding time

K

Kevin Chandler

Greetings to All,

I have a c# conversion app that does a lot of crunching and updates a status
window containing a RichText control. The updates to the control do not
appear until the job is done and the processor is freed up. I know in C++
you could pump some messages and the update would happen. I know in VB,
they had a call which would yield a minimum amount of time in order to
process events and update the display. What is available in C#?

Thanks in advance,
Kevin
 
J

Jon Skeet

Kevin Chandler said:
I have a c# conversion app that does a lot of crunching and updates a status
window containing a RichText control. The updates to the control do not
appear until the job is done and the processor is freed up. I know in C++
you could pump some messages and the update would happen. I know in VB,
they had a call which would yield a minimum amount of time in order to
process events and update the display. What is available in C#?

You should start the work in another thread, leaving the UI thread for
UI events. Note that any status updates or whatever should occur in the
UI thread too - use Control.Invoke to easily achieve this.
 
K

Kevin Chandler

Thanks!

It worked great. I should have known better. Suffering from a brain-fade.

Kevin
 
P

Paul E Collins

Kevin Chandler said:
I have a c# conversion app that does a lot of
crunching and updates a status window
containing a RichText control. [...]
I know in VB, they had a call which would yield
a minimum amount of time in order to process
events and update the display.

If you don't want to go the multi-threaded route, you can still use DoEvents
as you did in VB. The equivalent C# call is Application.DoEvents().

P.
 

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