Re: BackgroundWorker problems
"Lisle, Ron" <[email protected]>
| Newsgroups | gmane.comp.windows.dotnet.nunit.user |
|---|---|
| Message-ID | <[email protected]> |
I restructured the code to ensure that parts weren't being freed, but still ran into problems. I then starting working backwards from the example BackgroundWorker which did work ok with NUnit, and it appears that the culprit is the System.Windows.Form object. For some reason, if my class which contains the BackgroundWorker object is derived from System.Windows.Form, then only the DoWork event gets called. Seems a bit odd, since the BackgroundWorker object is intended to be placed onto a form, and it appears to work ok in the production code. I'm going to see if I can restructure remove the BackgroundWorker object from the form, and put it in a contained object not derived from Form. Any ideas why deriving from System.Windows.Form would cause the events to stop working? ________________________________ From: Nassar, Anthony [mailto:[email protected]] Sent: Tuesday, November 13, 2007 12:32 PM To: Lisle, Ron; [email protected] Subject: RE: [Nunit-users] BackgroundWorker problems I think I've figured out the problem. NUnit has no reason to keep your fixture class around once it's executed the small number of unit tests in it, right? So the entire AppDomain is unloaded, and therefore the form, and the BackgroundWorker component on it, get killed. The form's OnDisposed and OnClosing methods never even get called; likewise the completion callback. I don't think you can do what you're trying to do here, though I'm not sure exactly what you're trying to do. You're basically hoping that the background task will complete before the appropriate test is called. Unless you synchronize the thread on which the tests are running and the background thread onto which the task is put, that's not gonna happen. When I built delays in, the AppDomain still got unloaded by the test runner (I'm using ReSharper, but it doesn't matter). ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Nunit-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nunit-users