Yield control to windows for screen update

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
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
 
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
 
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
 
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
 
Back
Top