1
0
Эх сурвалжийг харах

Remove HAS_DISPATCHER_PRIORITY

Oren Novotny 8 жил өмнө
parent
commit
4b23f0f879

+ 8 - 29
Rx.NET/Source/System.Reactive.Windows.Threading/Reactive/Concurrency/DispatcherScheduler.cs

@@ -25,11 +25,8 @@ namespace System.Reactive.Concurrency
             get
             {
                 return new DispatcherScheduler(
-#if USE_SL_DISPATCHER
-                    System.Windows.Deployment.Current.Dispatcher
-#else
+
                     System.Windows.Threading.Dispatcher.CurrentDispatcher
-#endif
                 );
             }
         }
@@ -41,23 +38,18 @@ namespace System.Reactive.Concurrency
         {
             get
             {
-#if USE_SL_DISPATCHER
-                return new DispatcherScheduler(System.Windows.Deployment.Current.Dispatcher);
-#else
                 var dispatcher = System.Windows.Threading.Dispatcher.FromThread(Thread.CurrentThread);
                 if (dispatcher == null)
                     throw new InvalidOperationException(Strings_WindowsThreading.NO_DISPATCHER_CURRENT_THREAD);
 
                 return new DispatcherScheduler(dispatcher);
-#endif
+
             }
         }
 
         System.Windows.Threading.Dispatcher _dispatcher;
-
-#if HAS_DISPATCHER_PRIORITY
         System.Windows.Threading.DispatcherPriority _priority;
-#endif
+
 
         /// <summary>
         /// Constructs a DispatcherScheduler that schedules units of work on the given <see cref="System.Windows.Threading.Dispatcher"/>.
@@ -70,12 +62,10 @@ namespace System.Reactive.Concurrency
                 throw new ArgumentNullException(nameof(dispatcher));
 
             _dispatcher = dispatcher;
-#if HAS_DISPATCHER_PRIORITY
             _priority = Windows.Threading.DispatcherPriority.Normal;
-#endif
-        }
 
-#if HAS_DISPATCHER_PRIORITY
+        }
+        
         /// <summary>
         /// Constructs a DispatcherScheduler that schedules units of work on the given <see cref="System.Windows.Threading.Dispatcher"/> at the given priority.
         /// </summary>
@@ -90,7 +80,7 @@ namespace System.Reactive.Concurrency
             _dispatcher = dispatcher;
             _priority = priority;
         }
-#endif
+
 
         /// <summary>
         /// Gets the <see cref="System.Windows.Threading.Dispatcher"/> associated with the DispatcherScheduler.
@@ -99,8 +89,7 @@ namespace System.Reactive.Concurrency
         {
             get { return _dispatcher; }
         }
-
-#if HAS_DISPATCHER_PRIORITY
+        
         /// <summary>
         /// Gets the priority at which work items will be dispatched.
         /// </summary>
@@ -108,7 +97,7 @@ namespace System.Reactive.Concurrency
         {
             get { return _priority; }
         }
-#endif
+
 
         /// <summary>
         /// Schedules an action to be executed on the dispatcher.
@@ -131,9 +120,7 @@ namespace System.Reactive.Concurrency
                     if (!d.IsDisposed)
                         d.Disposable = action(this, state);
                 })
-#if HAS_DISPATCHER_PRIORITY
                 , _priority
-#endif
             );
 
             return d;
@@ -160,11 +147,7 @@ namespace System.Reactive.Concurrency
             var d = new MultipleAssignmentDisposable();
 
             var timer = new System.Windows.Threading.DispatcherTimer(
-#if HAS_DISPATCHER_PRIORITY
                 _priority, _dispatcher
-#elif DESKTOPCLR40 // BACKWARDS COMPATIBILITY with v1.x
-                System.Windows.Threading.DispatcherPriority.Background, _dispatcher
-#endif
             );
 
             timer.Tick += (s, e) =>
@@ -218,11 +201,7 @@ namespace System.Reactive.Concurrency
                 throw new ArgumentNullException(nameof(action));
 
             var timer = new System.Windows.Threading.DispatcherTimer(
-#if HAS_DISPATCHER_PRIORITY
                 _priority, _dispatcher
-#elif DESKTOPCLR40 // BACKWARDS COMPATIBILITY with v1.x
-                System.Windows.Threading.DispatcherPriority.Background, _dispatcher
-#endif
             );
 
             var state1 = state;

+ 9 - 76
Rx.NET/Source/System.Reactive.Windows.Threading/Reactive/Linq/DispatcherObservable.cs

@@ -33,8 +33,7 @@ namespace System.Reactive.Linq
 
             return ObserveOn_<TSource>(source, dispatcher);
         }
-
-#if HAS_DISPATCHER_PRIORITY
+        
         /// <summary>
         /// Wraps the source sequence in order to run its observer callbacks on the specified dispatcher.
         /// </summary>
@@ -53,7 +52,6 @@ namespace System.Reactive.Linq
 
             return ObserveOn_<TSource>(source, dispatcher, priority);
         }
-#endif
 
         /// <summary>
         /// Wraps the source sequence in order to run its observer callbacks on the specified dispatcher scheduler.
@@ -69,33 +67,11 @@ namespace System.Reactive.Linq
                 throw new ArgumentNullException(nameof(source));
             if (scheduler == null)
                 throw new ArgumentNullException(nameof(scheduler));
-
-#if HAS_DISPATCHER_PRIORITY
+            
             return ObserveOn_<TSource>(source, scheduler.Dispatcher, scheduler.Priority);
-#else
-            return ObserveOn_<TSource>(source, scheduler.Dispatcher);
-#endif
         }
 
-#if USE_SL_DISPATCHER
-        /// <summary>
-        /// Wraps the source sequence in order to run its observer callbacks on the dispatcher associated with the specified object.
-        /// </summary>
-        /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
-        /// <param name="source">Source sequence.</param>
-        /// <param name="dependencyObject">Object to get the dispatcher from.</param>
-        /// <returns>The source sequence whose observations happen on the specified object's dispatcher.</returns>
-        /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="dependencyObject"/> is null.</exception>
-        public static IObservable<TSource> ObserveOn<TSource>(this IObservable<TSource> source, DependencyObject dependencyObject)
-        {
-            if (source == null)
-                throw new ArgumentNullException("source");
-            if (dependencyObject == null)
-                throw new ArgumentNullException("dependencyObject");
 
-            return ObserveOn_<TSource>(source, dependencyObject.Dispatcher);
-        }
-#else
         /// <summary>
         /// Wraps the source sequence in order to run its observer callbacks on the dispatcher associated with the specified object.
         /// </summary>
@@ -113,9 +89,7 @@ namespace System.Reactive.Linq
 
             return ObserveOn_<TSource>(source, dispatcherObject.Dispatcher);
         }
-#endif
 
-#if HAS_DISPATCHER_PRIORITY
         /// <summary>
         /// Wraps the source sequence in order to run its observer callbacks on the dispatcher associated with the specified object.
         /// </summary>
@@ -134,7 +108,7 @@ namespace System.Reactive.Linq
 
             return ObserveOn_<TSource>(source, dispatcherObject.Dispatcher, priority);
         }
-#endif
+
 
         /// <summary>
         /// Wraps the source sequence in order to run its observer callbacks on the dispatcher associated with the current thread.
@@ -148,14 +122,9 @@ namespace System.Reactive.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-#if USE_SL_DISPATCHER
-            return ObserveOn_<TSource>(source, System.Windows.Deployment.Current.Dispatcher);
-#else
             return ObserveOn_<TSource>(source, DispatcherScheduler.Current.Dispatcher);
-#endif
         }
-
-#if HAS_DISPATCHER_PRIORITY
+        
         /// <summary>
         /// Wraps the source sequence in order to run its observer callbacks on the dispatcher associated with the current thread.
         /// </summary>
@@ -176,7 +145,7 @@ namespace System.Reactive.Linq
         {
             return Synchronization.ObserveOn(source, new DispatcherSynchronizationContext(dispatcher, priority));
         }
-#endif
+
 
         private static IObservable<TSource> ObserveOn_<TSource>(IObservable<TSource> source, Dispatcher dispatcher)
         {
@@ -208,8 +177,7 @@ namespace System.Reactive.Linq
 
             return SubscribeOn_<TSource>(source, dispatcher);
         }
-
-#if HAS_DISPATCHER_PRIORITY
+        
         /// <summary>
         /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified dispatcher.
         /// </summary>
@@ -232,7 +200,7 @@ namespace System.Reactive.Linq
 
             return SubscribeOn_<TSource>(source, dispatcher, priority);
         }
-#endif
+
 
         /// <summary>
         /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified dispatcher scheduler.
@@ -253,36 +221,9 @@ namespace System.Reactive.Linq
             if (scheduler == null)
                 throw new ArgumentNullException(nameof(scheduler));
 
-#if HAS_DISPATCHER_PRIORITY
             return SubscribeOn_<TSource>(source, scheduler.Dispatcher, scheduler.Priority);
-#else
-            return SubscribeOn_<TSource>(source, scheduler.Dispatcher);
-#endif
         }
 
-#if USE_SL_DISPATCHER
-        /// <summary>
-        /// Wraps the source sequence in order to run its subscription and unsubscription logic on the dispatcher associated with the specified object.
-        /// </summary>
-        /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
-        /// <param name="source">Source sequence.</param>
-        /// <param name="dependencyObject">Object to get the dispatcher from.</param>
-        /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified object's dispatcher.</returns>
-        /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="dependencyObject"/> is null.</exception>
-        /// <remarks>
-        /// Only the side-effects of subscribing to the source sequence and disposing subscriptions to the source sequence are run on the dispatcher associated with the specified object.
-        /// In order to invoke observer callbacks on the dispatcher associated with the specified object, e.g. to render results in a control, use <see cref="DispatcherObservable.ObserveOn{TSource}(IObservable{TSource}, DependencyObject)"/>.
-        /// </remarks>
-        public static IObservable<TSource> SubscribeOn<TSource>(this IObservable<TSource> source, DependencyObject dependencyObject)
-        {
-            if (source == null)
-                throw new ArgumentNullException("source");
-            if (dependencyObject == null)
-                throw new ArgumentNullException("dependencyObject");
-
-            return SubscribeOn_<TSource>(source, dependencyObject.Dispatcher);
-        }
-#else
         /// <summary>
         /// Wraps the source sequence in order to run its subscription and unsubscription logic on the dispatcher associated with the specified object.
         /// </summary>
@@ -304,9 +245,7 @@ namespace System.Reactive.Linq
 
             return SubscribeOn_<TSource>(source, dispatcherObject.Dispatcher);
         }
-#endif
-
-#if HAS_DISPATCHER_PRIORITY
+        
         /// <summary>
         /// Wraps the source sequence in order to run its subscription and unsubscription logic on the dispatcher associated with the specified object.
         /// </summary>
@@ -329,7 +268,6 @@ namespace System.Reactive.Linq
 
             return SubscribeOn_<TSource>(source, dispatcherObject.Dispatcher, priority);
         }
-#endif
 
         /// <summary>
         /// Wraps the source sequence in order to run its subscription and unsubscription logic on the dispatcher associated with the current thread.
@@ -347,14 +285,9 @@ namespace System.Reactive.Linq
             if (source == null)
                 throw new ArgumentNullException(nameof(source));
 
-#if USE_SL_DISPATCHER
-            return SubscribeOn_<TSource>(source, System.Windows.Deployment.Current.Dispatcher);
-#else
             return SubscribeOn_<TSource>(source, DispatcherScheduler.Current.Dispatcher);
-#endif
         }
 
-#if HAS_DISPATCHER_PRIORITY
         /// <summary>
         /// Wraps the source sequence in order to run its subscription and unsubscription logic on the dispatcher associated with the current thread.
         /// </summary>
@@ -379,7 +312,7 @@ namespace System.Reactive.Linq
         {
             return Synchronization.SubscribeOn(source, new DispatcherSynchronizationContext(dispatcher, priority));
         }
-#endif
+
 
         private static IObservable<TSource> SubscribeOn_<TSource>(IObservable<TSource> source, Dispatcher dispatcher)
         {

+ 2 - 2
Rx.NET/Source/System.Reactive/System.Reactive.csproj

@@ -24,11 +24,11 @@
     <AssemblyVersion>4.0.3000.0</AssemblyVersion>
   </PropertyGroup>
   <PropertyGroup Condition="'$(TargetFramework)' == 'net45'">
-    <DefineConstants>$(DefineConstants);NO_EVENTARGS_CONSTRAINT;HAS_WINRT;PREFER_ASYNC;USE_TIMER_SELF_ROOT;HAS_DISPATCHER_PRIORITY;HAS_WINFORMS;DESKTOPCLR;DESKTOPCLR45</DefineConstants>
+    <DefineConstants>$(DefineConstants);NO_EVENTARGS_CONSTRAINT;HAS_WINRT;PREFER_ASYNC;USE_TIMER_SELF_ROOT;HAS_WINFORMS;DESKTOPCLR;DESKTOPCLR45</DefineConstants>
     <AssemblyVersion>4.0.1000.0</AssemblyVersion>
   </PropertyGroup>
   <PropertyGroup Condition="'$(TargetFramework)' == 'net46'">
-    <DefineConstants>$(DefineConstants);NO_EVENTARGS_CONSTRAINT;HAS_WINRT;PREFER_ASYNC;USE_TIMER_SELF_ROOT;HAS_TPL46;HAS_DISPATCHER_PRIORITY;HAS_WINFORMS;DESKTOPCLR;DESKTOPCLR46</DefineConstants>
+    <DefineConstants>$(DefineConstants);NO_EVENTARGS_CONSTRAINT;HAS_WINRT;PREFER_ASYNC;USE_TIMER_SELF_ROOT;HAS_TPL46;HAS_WINFORMS;DESKTOPCLR;DESKTOPCLR46</DefineConstants>
     <AssemblyVersion>4.0.3000.0</AssemblyVersion>
   </PropertyGroup>
   <PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0'">