© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•7mo ago•
7 replies
CEO da CloudFlare

How to ensure Dispose() is called?

I have an
IDisposable
IDisposable
class that deals with Puppeteer performing tests and it closes the browser correctly after the end of the test. The problem is that, when I'm debugging and stop the debugger, the
Dispose()
Dispose()
of this class is not invoked, and the browser remains active, until I see that I have 30 instances of browsers without a parent. I'm running in headless mode so i cant see them in the taskbar.

This also occurs with unhandled exceptions - but I can deal with this using
try...catch
try...catch
during the test.

The real problem is when I forcibly end the process: I needed to make sure that the test browser will also be closed, or better, that my unmanaged resources are discarded after the end of the program, whether by love or by pain.

How do I deal with this?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to effectively dispose unmanaged resources?
C#CC# / help
3y ago
✅ Dispose method to "dispose" file resource when using LogTo method
C#CC# / help
11mo ago
HttpListener implements IDisposable but there is not Dispose() method, why and how can I dispose it?
C#CC# / help
2y ago