Sfoglia il codice sorgente

Workaround the 0ms timespan issue by falling back to the stopwatch timer on WinRT

Oren Novotny 9 anni fa
parent
commit
110be88170

+ 8 - 0
Rx.NET/Source/System.Reactive.Core/Reactive/Concurrency/Scheduler.Services.Emulation.cs

@@ -259,7 +259,15 @@ namespace System.Reactive.Concurrency
             //       events through IHostLifecycleNotifications, discovered through the PEP in order
             //       to maintain portability of the core of Rx.
             //
+
             var periodic = scheduler.AsPeriodic();
+#if WINDOWS
+            // Workaround for WinRT not supporting <1ms resolution
+            if(period < TimeSpan.FromMilliseconds(1))
+            {
+                periodic = null; // skip the periodic scheduler and use the stopwatch
+            }
+#endif
             if (periodic != null)
             {
                 return periodic.SchedulePeriodic(state, period, action);

+ 91 - 2
Rx.NET/Source/System.Reactive.Core/project.json

@@ -29,7 +29,7 @@
     "System.Diagnostics.Contracts": "4.0.1",
     "System.Dynamic.Runtime": "4.0.11"
   },
-  
+
   "frameworks": {
     "net45": {
       "buildOptions": {
@@ -120,7 +120,7 @@
           "HAS_AWAIT",
           "HAS_APTCA",
           "NO_REMOTING",
-          "NO_SERIALIZABLE",          
+          "NO_SERIALIZABLE",
           "CRIPPLED_REFLECTION",
           "PLIB",
           "USE_TIMER_SELF_ROOT"
@@ -130,6 +130,95 @@
         "System.Threading.Thread": "4.0.0",
         "System.Threading.ThreadPool": "4.0.10"
       }
+    },
+    "wpa81": {
+      "buildOptions": {
+        "define": [
+          "NO_EVENTARGS_CONSTRAINT",
+          "HAS_EDI",
+          "HAS_WINRT",
+          "HAS_PROGRESS",
+          "PREFER_ASYNC",
+          "HAS_AWAIT",
+          "NO_REMOTING",
+          "NO_SERIALIZABLE",
+          "NO_THREAD",
+          "CRIPPLED_REFLECTION",
+          "USE_TIMER_SELF_ROOT",
+          "WINDOWS",
+          "WINDOWS81"
+        ]
+      },
+      "dependencies": {
+        "Microsoft.TargetingPack.Private.WinRT": {
+          "version": "1.0.1",
+          "type": "build"
+        },
+        "Microsoft.TargetingPack.Private.WindowsPhone.v8.1": {
+          "version": "1.0.1",
+          "type": "build"
+        }
+      }
+    },
+    "netcore451": {
+      "buildOptions": {
+        "define": [
+          "NO_EVENTARGS_CONSTRAINT",
+          "HAS_EDI",
+          "HAS_WINRT",
+          "HAS_PROGRESS",
+          "PREFER_ASYNC",
+          "HAS_AWAIT",
+          "NO_REMOTING",
+          "NO_SERIALIZABLE",
+          "NO_THREAD",
+          "CRIPPLED_REFLECTION",
+          "USE_TIMER_SELF_ROOT",
+          "WINDOWS",
+          "WINDOWS81"
+        ]
+      },
+      "dependencies": {
+        "Microsoft.TargetingPack.Private.WinRT": {
+          "version": "1.0.1",
+          "type": "build"
+        },
+        "Microsoft.TargetingPack.Private.NETCore.v4.5.1": {
+          "version": "1.0.0",
+          "type": "build"
+        }
+      }
+    },
+    "uap10.0": {
+      "imports": [ "dotnet5.4" ],
+      "buildOptions": {
+        "define": [
+          "NO_EVENTARGS_CONSTRAINT",
+          "HAS_EDI",
+          "HAS_WINRT",
+          "HAS_PROGRESS",
+          "PREFER_ASYNC",
+          "HAS_AWAIT",
+          "HAS_APTCA",
+          "HAS_TPL46",
+          "NO_REMOTING",
+          "NO_SERIALIZABLE",
+          "NO_THREAD",
+          "CRIPPLED_REFLECTION",
+          "WINDOWS",
+          "USE_TIMER_SELF_ROOT"
+        ]
+      },
+      "dependencies": {
+        "Microsoft.TargetingPack.Private.WinRT": {
+          "version": "1.0.1",
+          "type": "build"
+        },
+        "Microsoft.NETCore.UniversalWindowsPlatform": {
+          "version": "5.2.0",
+          "type": "build"
+        }
+      }
     }
   }
 }

+ 1 - 1
Rx.NET/Source/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj

@@ -394,7 +394,7 @@
       <HintPath>..\Microsoft.Reactive.Testing\bin\$(Configuration)\uap10.0\Microsoft.Reactive.Testing.dll</HintPath>
     </Reference>
     <Reference Include="System.Reactive.Core">
-      <HintPath>..\System.Reactive.Core\bin\$(Configuration)\netstandard1.3\System.Reactive.Core.dll</HintPath>
+      <HintPath>..\System.Reactive.Core\bin\$(Configuration)\uap10.0\System.Reactive.Core.dll</HintPath>
     </Reference>
     <Reference Include="System.Reactive.Experimental">
       <HintPath>..\System.Reactive.Experimental\bin\$(Configuration)\netstandard1.3\System.Reactive.Experimental.dll</HintPath>