Re: BackgroundWorker problems
"Ian Wood" <[email protected]>
| Newsgroups | gmane.comp.windows.dotnet.nunit.user |
|---|---|
| Message-ID | <[email protected]> |
> Any ideas why deriving from System.Windows.Form would cause the events to stop working? Could it be due to the fact Form implements IDisposable and maybe that's getting called and it recursively disposing its components? How are you getting on with this problem? Would be interested to know how you solve it. Best regards, Ian ________________________________ From: [email protected] [mailto:[email protected]] On Behalf Of Lisle, Ron Sent: 13 November 2007 21:02 To: Nassar, Anthony; [email protected] Subject: Re: [Nunit-users] BackgroundWorker problems 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). www.sucden.co.uk Sucden (UK) Limited, 5 London Bridge Street, London SE1 9SG Telephone +44 20 7940 9400 Registered in England no. 1095841 VAT registration no. GB 446 9061 33 Authorised and Regulated by the Financial Services Authority (FSA) and entered in the FSA register under no. 114239 This email, including any files transmitted with it, is confidential and may be privileged. It may be read, copied and used only by the intended recipient. If you are not the intended recipient of this message, please notify [email protected] immediately and delete it from your computer system. We believe, but do not warrant, that this email and its attachments are virus-free, but you should check. Sucden (UK) Ltd may monitor traffic data of both business and personal emails. By replying to this email, you consent to Sucden?s monitoring the content of any emails you send to or receive from Sucden. Sucden is not liable for any opinions expressed by the sender where this is a non-business email. The contents of this e-mail do not constitute advice and should not be regarded as a recommendation to buy, sell or otherwise deal with any particular investment. This message has been scanned for viruses by BlackSpider MailControl ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Nunit-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nunit-users