G
Guest
Hi,
I'm trying to use the BackgroundWorker class from OpenNetCF SDF 1.4 in a CF
2.0 app, getting some very unexpected behaviour. So firstly, I need to
confirm my understanding of how things are supposed to work:
I perform 'work' on inside the DoWork event handler, not referencing any UI
components. The DoWork event is raised on another (background, non UI)
thread. As I perform 'work' I can use the ReportProgress method from inside
the DoWork event handler which will raise the ProgressChanged event on the UI
thread sometime later. Then once the DoWork event handler has returned, the
RunWorkerCompleted event will fire.
I'm finding that the only way things work as expected is if I *only* make
calls to ReportProgress inside the DoWork event handler. As soon as I do
ANYTHING else (eg Console.Out or construct a new object), the
RunWorkerCompleted event fires, and no further code inside the DoWork event
handler are executed. So if I have 10 lines of code, the first line of code
will execute, then the RunWorkerCompleted event fires, and no further lines
of code run.
I've been testing this with breakpoints which at first I suspected would be
adversly affecting things, but even when I compile with my second line of
'work' code being a simple 'throw new Exception()' and run the app outside of
VS I can see this second line of code never runs.
I'm using the PRO version of VS 05 on an XDA II device.
Anyone share this experience or have any ideas? I would dearly love to use
this class instead of the usual mess I make running 'long running work' in
the background... Thanks in advance.
I'm trying to use the BackgroundWorker class from OpenNetCF SDF 1.4 in a CF
2.0 app, getting some very unexpected behaviour. So firstly, I need to
confirm my understanding of how things are supposed to work:
I perform 'work' on inside the DoWork event handler, not referencing any UI
components. The DoWork event is raised on another (background, non UI)
thread. As I perform 'work' I can use the ReportProgress method from inside
the DoWork event handler which will raise the ProgressChanged event on the UI
thread sometime later. Then once the DoWork event handler has returned, the
RunWorkerCompleted event will fire.
I'm finding that the only way things work as expected is if I *only* make
calls to ReportProgress inside the DoWork event handler. As soon as I do
ANYTHING else (eg Console.Out or construct a new object), the
RunWorkerCompleted event fires, and no further code inside the DoWork event
handler are executed. So if I have 10 lines of code, the first line of code
will execute, then the RunWorkerCompleted event fires, and no further lines
of code run.
I've been testing this with breakpoints which at first I suspected would be
adversly affecting things, but even when I compile with my second line of
'work' code being a simple 'throw new Exception()' and run the app outside of
VS I can see this second line of code never runs.
I'm using the PRO version of VS 05 on an XDA II device.
Anyone share this experience or have any ideas? I would dearly love to use
this class instead of the usual mess I make running 'long running work' in
the background... Thanks in advance.