R
Rob R. Ainscough
I'm using a BackgroundWorker to perform a file download from an ftp site.
Per good code design practices where I separate my UI code from my core
logic code (in this case my Download file method in my FileIO class) I've
established Public Event in my core logic classes along with RaiseEvents
(that will updated a progress bar on the UI side). This all works great
when I'm NOT using Threading (BackgroundWorker), however, as soon as I
introduce threading and fire off the download via a BackgroundWorker
control, I get the above error whenever I issue an RaiseEvents in my core
code.
I've gone thru the many samples and noticed that none of them separate UI
code from logic code (perhaps to save time for purpose of demonstration).
So it appears that the simple approach of using BackGroundWorker is once
again not very useful for anyone implementing more professional code
design/solutions.
It would appear to me that if I want this to work correctly, I'd have to
pass to my core logic the background worker control? Not an option. Or,
setup a public event for the BackgroundWorker control and change my raise
event to reference the event that will trigger the background worker?
I must admit, I'm not sure why this limitation exists?
Rob
Per good code design practices where I separate my UI code from my core
logic code (in this case my Download file method in my FileIO class) I've
established Public Event in my core logic classes along with RaiseEvents
(that will updated a progress bar on the UI side). This all works great
when I'm NOT using Threading (BackgroundWorker), however, as soon as I
introduce threading and fire off the download via a BackgroundWorker
control, I get the above error whenever I issue an RaiseEvents in my core
code.
I've gone thru the many samples and noticed that none of them separate UI
code from logic code (perhaps to save time for purpose of demonstration).
So it appears that the simple approach of using BackGroundWorker is once
again not very useful for anyone implementing more professional code
design/solutions.
It would appear to me that if I want this to work correctly, I'd have to
pass to my core logic the background worker control? Not an option. Or,
setup a public event for the BackgroundWorker control and change my raise
event to reference the event that will trigger the background worker?
I must admit, I'm not sure why this limitation exists?
Rob