0
Reply

Setting form properties in a thread-safe way

Pieter De Decker

Pieter De Decker

Apr 30 2009 4:35 PM
2.8k
I want to do the following things in a BackgroundWorker:

this.Top = Screen.PrimaryScreen.WorkingArea.Height;
this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width;
this.Visible = true;

C# will give you one of those "thread-unsafe" warnings if you try to exectute this code in a BackgroundWorker. How can I do this in a thread-safe way?