|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ThreadingI made a Windows Project in 1.1 and converted it to 2.0 and get the following Error: "Cross-thread operation not valid: Control 'progressBar1' accessed from a thread other than the thread it was created on." I have a small form that is processing a lot of information and if the user moves the window or opens a new one and closes it, the form is not redrawn. You just get a while window. I managed to work around this in 1.1 using a new thread to do all the work and to refresh the form and a progress bar. Unfortunately, this does not work in 2.0. Any Suggestions will be greatly appreciated. Thanks, Chuck Charles A. Lackman <Char***@CreateItSoftware.net> wrote:
> I made a Windows Project in 1.1 and converted it to 2.0 and get the It doesn't *really* work in 1.1 either - not reliably. You should > following Error: > > "Cross-thread operation not valid: Control 'progressBar1' accessed from a > thread other than the thread it was created on." > > I have a small form that is processing a lot of information and if the user > moves the window or opens a new one and closes it, the form is not redrawn. > You just get a while window. > > I managed to work around this in 1.1 using a new thread to do all the work > and to refresh the form and a progress bar. Unfortunately, this does not > work in 2.0. always have been using Control.Invoke or Control.BeginInvoke to make sure the UI work is done on the UI thread. It's just that 2.0 gives you an error if you try to do it (in debug mode only). See http://www.pobox.com/~skeet/csharp/threads/winforms.shtml for information on how to do it properly. -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too |
|||||||||||||||||||||||