Meeting the needs of your business from a distance

Making Form Controls Thread Safe

by Mark Shiffer 11/20/2007 8:26:00 AM
I recently came across this tid-bit of information and thought I would document it for myself. Windows Forms controls are not thread safe. Therefore, when attempting to update a control from another thread you must take special precautions. An example of where this would be helpful would be in updating a progress bar or other UI control when running a batch process on another thread. To accomplish this, the InvokeRequired property of the control should be used along with the Invoke or BeginInvoke method. Invoke required will return True when the caller is on a different thread then the control was created on. In that case, you then need to call Invoke with a delegate that will get run on the control's thread.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

Research | Programs

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag





Live preview

July 9. 2008 00:27

About the author

Name of author Mark Shiffer
CEO & CIO of MS Consulting

E-mail me Send mail

Calendar

<<  July 2008  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar

Pages

    Recent posts

    Recent comments

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008

    Sign in

    Copyright © 2001-2008 MS Consulting, Inc. All Rights Reserved.