Skip to content

Commit 2823f4f

Browse files
author
Joshua Peterson
authored
Merge pull request #1340 from Unity-Technologies/network-changed-windows-not-supported
The NetworkChange event is not supported on Windows (case 1278048)
2 parents 68e4d5a + 0237a03 commit 2823f4f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

mcs/class/System/System.Net.NetworkInformation/NetworkChange.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ static void MaybeCreate ()
107107
if (networkChange != null)
108108
return;
109109

110+
if (IsWindows)
111+
throw new PlatformNotSupportedException ("NetworkInformation.NetworkChange is not supported on the current platform.");
110112
try {
111113
networkChange = new MacNetworkChange ();
112114
} catch {
@@ -117,6 +119,21 @@ static void MaybeCreate ()
117119
#endif // MONOTOUCH_WATCH
118120
}
119121

122+
static bool IsWindows
123+
{
124+
get
125+
{
126+
PlatformID platform = Environment.OSVersion.Platform;
127+
if (platform == PlatformID.Win32S ||
128+
platform == PlatformID.Win32Windows ||
129+
platform == PlatformID.Win32NT ||
130+
platform == PlatformID.WinCE) {
131+
return true;
132+
}
133+
return false;
134+
}
135+
}
136+
120137
static void MaybeDispose ()
121138
{
122139
if (networkChange != null && networkChange.HasRegisteredEvents) {

0 commit comments

Comments
 (0)