Re: Long Process

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On May 22, 1:15 am, Tom Shelton
<tom_shel...@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
On 2008-05-21, John Wright <riley_wri...@xxxxxxxxxxx> wrote:

When I do this I get a cross thread error. Any ideas?

John

John,

You can't access any of the forms controls in the actual DoWork event.
You need to handle any updates during your work by calling the
ReportProgress method of the backgroundworker. This will cause the
ProgressChanged event to be raised (assuming you have set the
WorkerReportsProgress property to true). In that event it is safe to
access your forms controls.

--
Tom Shelton


Hi,
Tom is right, and your form elements are getting updated and accessed
during BackgroundWorker's DoWork event, that's why the reason of error
i guess.

Thanks,

Onur Güzel
.



Relevant Pages

  • Re: arrays containing radiobuttons
    ... Tom Shelton wrote: ... Chris Dunaway wrote: ... > Sometimes, though, if you are dynamically adding controls at runtime, ... Prev by Date: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Aysnc Update of Datagrid = Empty?
    ... Tom Shelton wrote in news:OghcgJpJEHA.3380 ... > all calls to the form and it's controls back to the GUI thread. ... > an msdn article on the subject - the code is in C#, ...
    (microsoft.public.dotnet.languages.vb)
  • add controls from another process using backgroundworker
    ... I have winForm that needs update Panel (add controls to Panel of ... and DoWork event I want to add controls but I get ... subproceso no pueden tener controles primarios en un control en un subproceso ...
    (microsoft.public.dotnet.languages.csharp)