thread safety

by Eren 7. December 2007 03:50

By default, a Windows application uses a single thread of execution. And when you have multiple threads of
execution (like what you did here with the ReceiveMessage() subroutine), things get a little complicated
when you try to update the UI of the application from different threads.

It is important to note that you cannot directly access the properties of Windows controls on separate
threads (other than on the main thread that it is running on), because Windows controls are not thread-safe.
Trying to do so will also trigger a runtime error, a useful feature new in Visual Studio 2005. Instead, you
should use a delegate and call it using the Invoke()/BeginInvoke() method of the controls/form
you are trying to update.

 

Tags:

C#.NET

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Hakkımda Kısaca

Eren Çetin

Bilgisayar Mühendisi

İstanbul / Turkiye

Eren Çetin - 2010
Eren Çetin, Bilgisayar Mühendisi , Yazılım Geliştirme Uzmanı