use background thread to wait for address changes on OSX (dotnet/corefx#41768)
authorTomas Weinfurt <tweinfurt@yahoo.com>
Wed, 16 Oct 2019 05:10:51 +0000 (22:10 -0700)
committerGitHub <noreply@github.com>
Wed, 16 Oct 2019 05:10:51 +0000 (22:10 -0700)
* use background thread to wait for address changes on OSX

* remove RemoteExecutor

* update comment

Commit migrated from https://github.com/dotnet/corefx/commit/08bf1fec4bbb44bab804f068878812aacb06b4d0

src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs
src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/NetworkAvailabilityChangedTests.cs

index baa6ecd..b5187e1 100644 (file)
@@ -181,6 +181,7 @@ namespace System.Net.NetworkInformation
                 }
             }
             s_runLoopThread = new Thread(RunLoopThreadStart);
+            s_runLoopThread.IsBackground = true;
             s_runLoopThread.Start();
             s_runLoopStartedEvent.WaitOne(); // Wait for the new thread to finish initialization.
         }
index fde4b4f..138890a 100644 (file)
@@ -29,6 +29,20 @@ namespace System.Net.NetworkInformation.Tests
 
         [Fact]
         [ActiveIssue(33530, TestPlatforms.FreeBSD)]
+        public void NetworkAddressChanged_Add_DoesNotBlock()
+        {
+            // Register without unregistering.
+            // This should not block process exit. If it does, this test will pass
+            // but we would fail to exit test run at the end.
+            // We cannot test this via RemoteInvoke() as that calls Environment.Exit()
+            // and forces quit even when foreground threads are running.
+            NetworkChange.NetworkAddressChanged += _addressHandler;
+            {
+            };
+        }
+
+        [Fact]
+        [ActiveIssue(33530, TestPlatforms.FreeBSD)]
         public void NetworkAddressChanged_AddAndRemove_NetworkAvailabilityChanged_JustRemove_Success()
         {
             NetworkChange.NetworkAddressChanged += _addressHandler;