@@ -193,15 +193,13 @@ namespace Microsoft.FSharp.Control
193193
194194static let unfake FakeUnit = ()
195195// preallocate context-switching callbacks
196- #if ! FX_ NO_ SYNC_ CONTEXT
197196// Preallocate the delegate
198197// This should be the only call to SynchronizationContext.Post in this library. We must always install a trampoline.
199198let sendOrPostCallback =
200199 SendOrPostCallback( fun o ->
201200let f = unbox o: unit-> FakeUnitValue
202201 this.Protect f|> unfake
203202)
204- #endif
205203
206204// Preallocate the delegate
207205// This should be the only call to QueueUserWorkItem in this library. We must always install a trampoline.
@@ -220,11 +218,9 @@ namespace Microsoft.FSharp.Control
220218)
221219#endif
222220
223- #if ! FX_ NO_ SYNC_ CONTEXT
224221member this.Post ( ctxt : SynchronizationContext ) ( f : unit -> FakeUnitValue ) =
225222 ctxt.Post( sendOrPostCallback, state=( f|> box))
226223 FakeUnit
227- #endif
228224
229225member this.QueueWorkItem ( f : unit -> FakeUnitValue ) =
230226if not ( ThreadPool.QueueUserWorkItem( waitCallbackForQueueWorkItemWithTrampoline, f|> box)) then
@@ -643,11 +639,9 @@ namespace Microsoft.FSharp.Control
643639//----------------------------------
644640// DERIVED SWITCH TO HELPERS
645641
646- #if ! FX_ NO_ SYNC_ CONTEXT
647642let switchTo ( ctxt : SynchronizationContext ) =
648643 protectedPrimitive( fun ({ aux = aux } as args ) ->
649644 aux.trampolineHolder.Post ctxt( fun () -> args.cont() ))
650- #endif
651645
652646let switchToNewThread () =
653647 protectedPrimitive( fun ({ aux = aux } as args ) ->
@@ -670,14 +664,8 @@ namespace Microsoft.FSharp.Control
670664}
671665}
672666
673- #if FX_ NO_ SYNC_ CONTEXT
674- let getSyncContext _ = null
675- let delimitSyncContext args = args
676- let postOrQueue _ ( trampolineHolder : TrampolineHolder ) f =
677- trampolineHolder.QueueWorkItem f
678- #else
679667let getSyncContext () = System.Threading.SynchronizationContext.Current
680-
668+
681669let postOrQueue ( ctxt : SynchronizationContext ) ( trampolineHolder : TrampolineHolder ) f =
682670match ctxtwith
683671| null -> trampolineHolder.QueueWorkItem f
@@ -697,9 +685,6 @@ namespace Microsoft.FSharp.Control
697685 ccont= ( fun x -> trampolineHolder.Post ctxt( fun () -> aux.ccont x))
698686}
699687}
700-
701- #endif
702-
703688
704689// When run, ensures that each of the continuations of the process are run in the same synchronization context.
705690let protectedPrimitiveWithResync f =
@@ -730,19 +715,14 @@ namespace Microsoft.FSharp.Control
730715[<AutoSerializable( false ) >]
731716type SuspendedAsync < 'T >( args :AsyncParams < 'T >) =
732717let ctxt = getSyncContext()
733- #if ! FX_ NO_ SYNC_ CONTEXT
734718let thread =
735719match ctxtwith
736720| null -> null // saving a thread-local access
737721| _ -> Thread.CurrentThread
738- #endif
739722let trampolineHolder = args.aux.trampolineHolder
740723member this.ContinueImmediate res =
741724let action () = args.cont res
742725let inline executeImmediately () = trampolineHolder.Protect action
743- #if FX_ NO_ SYNC_ CONTEXT
744- executeImmediately()
745- #else
746726let currentCtxt = System.Threading.SynchronizationContext.Current
747727match ctxt, currentCtxtwith
748728| null , null ->
@@ -753,8 +733,7 @@ namespace Microsoft.FSharp.Control
753733 executeImmediately()
754734| _ ->
755735 postOrQueue ctxt trampolineHolder action
756- #endif
757-
736+
758737member this.ContinueWithPostOrQueue res =
759738 postOrQueue ctxt trampolineHolder( fun () -> args.cont res)
760739
@@ -1679,8 +1658,6 @@ namespace Microsoft.FSharp.Control
16791658
16801659return Async.AsyncWaitAsyncWithTimeout( innerCTS, resultCell, millisecondsTimeout) }
16811660
1682- #if ! FX_ NO_ SYNC_ CONTEXT
1683-
16841661static member SwitchToContext syncContext =
16851662async { match syncContextwith
16861663| null ->
@@ -1689,7 +1666,6 @@ namespace Microsoft.FSharp.Control
16891666| ctxt->
16901667// post the continuation to the synchronization context
16911668return ! switchTo ctxt}
1692- #endif
16931669
16941670static member OnCancel action =
16951671async { let! ct = getCancellationToken()