Click here to Skip to main content
15,898,942 members
Home / Discussions / C#
   

C#

 
GeneralRe: Update/Refresh Form Pin
Waleed Eissa15-Apr-08 5:56
Waleed Eissa15-Apr-08 5:56 
GeneralRe: Update/Refresh Form Pin
Alessandra7715-Apr-08 6:04
Alessandra7715-Apr-08 6:04 
GeneralRe: Update/Refresh Form Pin
Waleed Eissa15-Apr-08 6:06
Waleed Eissa15-Apr-08 6:06 
GeneralRe: Update/Refresh Form Pin
Alessandra7715-Apr-08 6:24
Alessandra7715-Apr-08 6:24 
GeneralRe: Update/Refresh Form Pin
Anthony Mushrow15-Apr-08 7:07
professionalAnthony Mushrow15-Apr-08 7:07 
GeneralRe: Update/Refresh Form Pin
Waleed Eissa15-Apr-08 20:44
Waleed Eissa15-Apr-08 20:44 
GeneralShowDialog from seperate thread Pin
lgelliott15-Apr-08 5:06
lgelliott15-Apr-08 5:06 
GeneralRe: ShowDialog from seperate thread Pin
Judah Gabriel Himango15-Apr-08 6:19
sponsorJudah Gabriel Himango15-Apr-08 6:19 
First, it sounds like you're abusing the BackgroundWorker. The BackgroundWorker is meant for running non-UI work on a background thread. If you want to update the UI during that work, call worker.ReportProgress, which will fire the ProgressChanged event on the UI thread. Also, the RunWorkerCompleted event will fire when the work is done, and it will fire on the UI thread.

If you really have to create forms or controls on a background thread, you must ensure that the thread is STA. Look at Thread.SetApartmentState before you start the thread. You can't make BackgroundWorker threads be STA, so the BackgroundWorker won't work for this.

Ideally, however, you use just a single thread to create and change your UI controls. Without this, you're going to have thread marshalling nightmares if different UIs need to be accessed on different threads.

To sum up, use a background worker to perform non-UI related work on a background thread. If you need to update the UI from this background thread, call worker.ReportProgress and do the UI update inside a worker.ProgressChanged event handler.





GeneralRe: ShowDialog from seperate thread Pin
lgelliott15-Apr-08 7:44
lgelliott15-Apr-08 7:44 
GeneralRe: ShowDialog from seperate thread Pin
Judah Gabriel Himango15-Apr-08 10:02
sponsorJudah Gabriel Himango15-Apr-08 10:02 
GeneralRe: ShowDialog from seperate thread Pin
lgelliott15-Apr-08 10:34
lgelliott15-Apr-08 10:34 
GeneralRe: ShowDialog from seperate thread Pin
Judah Gabriel Himango15-Apr-08 11:37
sponsorJudah Gabriel Himango15-Apr-08 11:37 
GeneralRe: ShowDialog from seperate thread Pin
lgelliott15-Apr-08 14:15
lgelliott15-Apr-08 14:15 
GeneralRe: ShowDialog from seperate thread Pin
lgelliott15-Apr-08 15:10
lgelliott15-Apr-08 15:10 
GeneralRe: ShowDialog from seperate thread Pin
Judah Gabriel Himango16-Apr-08 4:13
sponsorJudah Gabriel Himango16-Apr-08 4:13 
GeneralRe: ShowDialog from seperate thread Pin
lgelliott17-Apr-08 2:48
lgelliott17-Apr-08 2:48 
GeneralRe: ShowDialog from seperate thread Pin
Judah Gabriel Himango17-Apr-08 4:46
sponsorJudah Gabriel Himango17-Apr-08 4:46 
GeneralRe: ShowDialog from seperate thread Pin
lgelliott17-Apr-08 7:18
lgelliott17-Apr-08 7:18 
Generaldispose wrapped resource Pin
George_George15-Apr-08 4:46
George_George15-Apr-08 4:46 
GeneralRe: dispose wrapped resource Pin
Simon P Stevens15-Apr-08 5:03
Simon P Stevens15-Apr-08 5:03 
GeneralRe: dispose wrapped resource Pin
George_George15-Apr-08 5:07
George_George15-Apr-08 5:07 
GeneralRe: dispose wrapped resource Pin
Simon P Stevens15-Apr-08 7:34
Simon P Stevens15-Apr-08 7:34 
GeneralRe: dispose wrapped resource Pin
George_George15-Apr-08 23:25
George_George15-Apr-08 23:25 
GeneralRe: dispose wrapped resource Pin
Simon P Stevens16-Apr-08 1:21
Simon P Stevens16-Apr-08 1:21 
GeneralRe: dispose wrapped resource Pin
George_George16-Apr-08 1:55
George_George16-Apr-08 1:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.