Yield control to windows for screen update

G

Guest

Hello,

While in extensive math calculation in MFC application, i used to yield
control to window by calling this code:

void YieldControl( void )
{
MSG msg ;
if( ::peekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
::TranslateMessage( &msg ) ;
::DispatchMessage( &msg ) ;
}
}

How can I do similar thing in .Net application?

Thank you,
Eitan Barazani
 
N

Nicholas Paldino [.NET/C# MVP]

Eitan,

Yes, you could. You can call the static DoEvents method on the
Application class in order to process messages that are in the queue.

However, I STRONGLY advise against it. Rather, you should be performing
these calculations on another thread and then calling the Invoke method on a
control, passing a delegate to be executed on the UI thread when you need to
perform an update.
 
G

Guest

Thanks.

Any article that I should look into here?

Eitan

Nicholas Paldino said:
Eitan,

Yes, you could. You can call the static DoEvents method on the
Application class in order to process messages that are in the queue.

However, I STRONGLY advise against it. Rather, you should be performing
these calculations on another thread and then calling the Invoke method on a
control, passing a delegate to be executed on the UI thread when you need to
perform an update.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Eitan said:
Hello,

While in extensive math calculation in MFC application, i used to yield
control to window by calling this code:

void YieldControl( void )
{
MSG msg ;
if( ::peekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
::TranslateMessage( &msg ) ;
::DispatchMessage( &msg ) ;
}
}

How can I do similar thing in .Net application?

Thank you,
Eitan Barazani
 
N

Nicholas Paldino [.NET/C# MVP]

Eitan,

This is a pretty common question on the boards. You could search
google, or google groups, with the terms "threading windows forms invoke
delegate" and find a number of posts relating to the subject.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Eitan said:
Thanks.

Any article that I should look into here?

Eitan

Nicholas Paldino said:
Eitan,

Yes, you could. You can call the static DoEvents method on the
Application class in order to process messages that are in the queue.

However, I STRONGLY advise against it. Rather, you should be
performing
these calculations on another thread and then calling the Invoke method
on a
control, passing a delegate to be executed on the UI thread when you need
to
perform an update.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Eitan said:
Hello,

While in extensive math calculation in MFC application, i used to yield
control to window by calling this code:

void YieldControl( void )
{
MSG msg ;
if( ::peekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
::TranslateMessage( &msg ) ;
::DispatchMessage( &msg ) ;
}
}

How can I do similar thing in .Net application?

Thank you,
Eitan Barazani
 
A

AlexS

If you are not familiar with topic, start from this
http://msdn.microsoft.com/msdnmag/issues/03/02/Multithreading/

Nicholas Paldino said:
Eitan,

This is a pretty common question on the boards. You could search
google, or google groups, with the terms "threading windows forms invoke
delegate" and find a number of posts relating to the subject.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Eitan said:
Thanks.

Any article that I should look into here?

Eitan

Nicholas Paldino said:
Eitan,

Yes, you could. You can call the static DoEvents method on the
Application class in order to process messages that are in the queue.

However, I STRONGLY advise against it. Rather, you should be
performing
these calculations on another thread and then calling the Invoke method
on a
control, passing a delegate to be executed on the UI thread when you
need to
perform an update.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hello,

While in extensive math calculation in MFC application, i used to
yield
control to window by calling this code:

void YieldControl( void )
{
MSG msg ;
if( ::peekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
::TranslateMessage( &msg ) ;
::DispatchMessage( &msg ) ;
}
}

How can I do similar thing in .Net application?

Thank you,
Eitan Barazani
 
G

Guest

Alex, Thanks!
Eitan

AlexS said:
If you are not familiar with topic, start from this
http://msdn.microsoft.com/msdnmag/issues/03/02/Multithreading/

Nicholas Paldino said:
Eitan,

This is a pretty common question on the boards. You could search
google, or google groups, with the terms "threading windows forms invoke
delegate" and find a number of posts relating to the subject.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Eitan said:
Thanks.

Any article that I should look into here?

Eitan

:

Eitan,

Yes, you could. You can call the static DoEvents method on the
Application class in order to process messages that are in the queue.

However, I STRONGLY advise against it. Rather, you should be
performing
these calculations on another thread and then calling the Invoke method
on a
control, passing a delegate to be executed on the UI thread when you
need to
perform an update.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hello,

While in extensive math calculation in MFC application, i used to
yield
control to window by calling this code:

void YieldControl( void )
{
MSG msg ;
if( ::peekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
::TranslateMessage( &msg ) ;
::DispatchMessage( &msg ) ;
}
}

How can I do similar thing in .Net application?

Thank you,
Eitan Barazani
 

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