Hi Dave,
When a Form is loaded, it's Load event is fired first. The Form won't show
until all lines of code in its Load event handler finish executing. After
that, the Form's Activated event is fired and then the Shown event.
If the Form does some time-consuming work in the Activated or Shown event
handler, the UI of the Form will be blocked, i.e. all controls on the Form
are not painted properly or not responsive. This is because the main UI
thread is busy and doesn't have a chance to paint/refresh the UI of the
Form.
To show a Form and then do some time-consuming work without blocking the
UI, I suggest that you do the time-consuming work in a separate thread. You
can create a Thread instance or call the BeginInvoke method on the delegate
to the time-consuming method to do it, if you're using .NET 1.x.
If you're using .NET 2.0, I recommend you use the BackgroundWorker
component, which provides a concise multiple-threads programming model and
is very easy to use. You can start a BackgroundWorker in the Form's Load
event handler in your practice.
For more information on how to use the BackgroundWorker component, please
refer to the following MSDN document:
http://msdn.microsoft.com/en-us/libr...backgroundwork
er.aspx
Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.