Fix several Socket tests to not dispose an event (dotnet/corefx#42020)
authorStephen Toub <stoub@microsoft.com>
Wed, 23 Oct 2019 03:08:01 +0000 (23:08 -0400)
committerGitHub <noreply@github.com>
Wed, 23 Oct 2019 03:08:01 +0000 (23:08 -0400)
commit474e1d6fc6a0256cef2998894ff65b50be73fd57
tree195bbb16f897778521889d7386afc525202efdab
parentbdb751bf5277efae529361420bc21d9022325d62
Fix several Socket tests to not dispose an event (dotnet/corefx#42020)

When I run these tests locally, due to my network configuration they sometimes fail.  If they fail and the test is disposing of the ManualResetEvent, the async callback may try to set the event after it's already been disposed, which throws an exception that crashes the test process.  The easy fix is to just dispose of these MRE instances on success and let their finalizers clean up for them if the tests fail.

Commit migrated from https://github.com/dotnet/corefx/commit/623703d941115131a7f269f9e23560f6d937837c
src/libraries/System.Net.Sockets/tests/FunctionalTests/DnsEndPointTest.cs