Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncTimeoutTimer"/> class.
 /// </summary>
 public AsyncTimeoutTimer()
 {
     timer = new System.Timers.Timer();
     timer.AutoReset = false;
     timer.SynchronizingObject = new GenericSynchronizingObject();
     context = new CallbackContext();
 }
Exemplo n.º 2
0
 void CmBilling_OnBillingResult(string result)
 {
     Util.Log("BillingResult=" + result);
     string[] results = result.Split('|');
     int id = 0;
     if(!int.TryParse(results[0], out id))
     {
         Util.LogError("Billing result Error: " + result);
         return;
     }
     CallbackContext context = new CallbackContext();
     for(int i = 0; i < this.callbackContexts.Count; i ++)
     {
         if(this.callbackContexts[i].Parameter.ID == id)
         {
             context = this.callbackContexts[i];
             this.callbackContexts.RemoveAt(i);
             break;
         }
     }
     if(CmBillingAndroid.BillingResult.SUCCESS == results[1])
     {
         context.Callback(BuyResult.Success, context.Parameter);
         return;
     }
     context.Callback(BuyResult.Failure, context.Parameter);
 }
Exemplo n.º 3
0
        public void OnReturn(CallbackContext context)
        {
            if (context.phase != InputActionPhase.Started)
            {
                return;
            }

            Return();
        }
Exemplo n.º 4
0
 public void OnDodge(CallbackContext context)
 {
     Debug.Log("OnDodge ok");
     if (combat == null || inputBlock || !context.performed)
     {
         return;
     }
     combat.Dodge(context.ReadValue <float>());
 }
Exemplo n.º 5
0
 public void OnMove(CallbackContext context)
 {
     if (motor == null || inputBlock)
     {
         return;
     }
     move = context.ReadValue <Vector2>();
     motor.SetMoveDirection(move);
 }
Exemplo n.º 6
0
 public void OnJump(CallbackContext context)
 {
     isJumping         = context.performed;
     jumpActionExecute = isGrounded && isJumping;
     if (jumpActionExecute)
     {
         jumpTime = maxJumpTime;
     }
 }
Exemplo n.º 7
0
    private void LookAtMousePosition(CallbackContext ctx)
    {
        Vector3 mousePos = ctx.ReadValue <Vector2>();

        Vector3 direction = mousePos - Camera.main.WorldToScreenPoint(transform.position);
        float   angle     = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;

        transform.rotation = Quaternion.AngleAxis(angle - 90, Vector3.forward);
    }
Exemplo n.º 8
0
    // What happens for each input press

    // These functions are called by the input system with context to what has happened with the input
    public void Interact(CallbackContext context)
    {
        // Checks if the input has been pressed
        if (context.performed && playerMovement != null)
        {
            // If true then call Interact function
            playerCombat.Interact();
        }
    }
Exemplo n.º 9
0
 public void OnMove(CallbackContext movementContext)
 {
     if (playerMovement != null)
     {
         // Takes the input from object this script is attached to (PlayerInputController)
         playerMovement.SetInputVector(movementContext.ReadValue <Vector2>());
         playerCombat.SetInputAimVector(movementContext.ReadValue <Vector2>());
     }
 }
Exemplo n.º 10
0
        internal void Callback(object state)
        {
            CallbackContext context = (CallbackContext)state;

            context.result = context.policyWrapper.CheckErrors(context.hostName,
                                                               context.certificate,
                                                               context.chain,
                                                               context.sslPolicyErrors);
        }
Exemplo n.º 11
0
 protected virtual void InputFire(CallbackContext ctx)
 {
     if (!isReloading && Time.timeScale == 1 && !disableControls && firePoint && shellPrefab && timeSinceLastShot < Time.time)
     {
         HandleFireShot();
         weaponSourceSound.Play();
         timeSinceLastShot = Time.time + timeBetweenShots;
     }
 }
Exemplo n.º 12
0
    public void Aim(CallbackContext value)
    {
        Vector2 aimVal = value.ReadValue <Vector2>();

        if (aimVal != Vector2.zero)
        {
            aim = aimVal;
        }
    }
 public void OnPrimaryAttackInput(CallbackContext context)
 {
     if (context.started)
     {
         PrimaryAttackInput      = true;
         _primaryInputStartTime  = Time.time;
         PrimaryAttackClickCount = PrimaryAttackClickCount + 1 > _maxClickCount ? _startClickCount : PrimaryAttackClickCount + 1;
     }
 }
Exemplo n.º 14
0
        public void OnMove(CallbackContext ctx)
        {
            Vector2 direction = ctx.ReadValue <Vector2>();

            Debug.Log("OnMove");
            Debug.Log(direction);
            animator.SetFloat("vertical", direction.y);
            animator.SetFloat("horizontal", direction.x);
        }
Exemplo n.º 15
0
 private void OnTab(CallbackContext ctx)
 {
     if (m_hints == null || m_hints.Count < 1)
     {
         return;
     }
     m_input       = m_hints[m_index].Split(new char[] { ' ' })[0];
     m_cursorIndex = m_input.Length;
 }
Exemplo n.º 16
0
    public void EscapedInput(CallbackContext context)
    {
        if (!context.performed || !fader.visible)
        {
            return;
        }

        Hide();
    }
Exemplo n.º 17
0
        internal void Callback(object state)
        {
            CallbackContext context = (CallbackContext)state;

            context.result = m_ValidationCallback(context.request,
                                                  context.certificate,
                                                  context.chain,
                                                  context.sslPolicyErrors);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Growl通知の発行を行うメソッド
        /// </summary>
        /// <param name="notification">通知用データ</param>
        /// <param name="context">コールバック処理をしたい場合に指定</param>
        public void RunNotification(Notification notification, CallbackContext context = null)
        {
            if (notification == null)
            {
                throw new ArgumentNullException("notification");
            }

            Connector.Notify(notification, context);
        }
Exemplo n.º 19
0
    public void OnMove(CallbackContext context)
    {
        if (context.control.device.deviceId == inputDevice.deviceId)
        {
            Vector2 val = context.ReadValue <Vector2>();

            if (Mathf.Abs(val.x) < 0.5f)
            {
                return;
            }
            if ((context.startTime - startTime) < 0.25f)
            {
                return;
            }

            switch (currentSlot)
            {
            case PlayerID.NP:
                if (val.x > 0)
                {
                    if (joiner.TryJoin(PlayerID.Player2, inputDevice))
                    {
                        ToggleState(PlayerID.Player2);
                        startTime = context.startTime;
                    }
                }
                else
                {
                    if (joiner.TryJoin(PlayerID.Player1, inputDevice))
                    {
                        ToggleState(PlayerID.Player1);
                        startTime = context.startTime;
                    }
                }
                break;

            case PlayerID.Player1:
                if (val.x > 0)
                {
                    ToggleState(PlayerID.NP);
                    startTime = context.startTime;
                    joiner.RemovePlayer(inputDevice);
                }
                break;

            case PlayerID.Player2:
                if (val.x < 0)
                {
                    ToggleState(PlayerID.NP);
                    startTime = context.startTime;
                    joiner.RemovePlayer(inputDevice);
                }
                break;
            }
        }
    }
Exemplo n.º 20
0
    public void NextDialogue(CallbackContext context)
    {
        if (!context.performed)
        {
            return;
        }

        currentStripIndex = currentStripIndex + 1 > currentStrip.dialogueList.Count - 1 ? 0 : currentStripIndex + 1;
        DisplayDialogue(currentStrip.dialogueList[currentStripIndex]);
    }
Exemplo n.º 21
0
    /// <summary>
    /// Handles WASD input and saves the input for FixedUpdate to handle
    /// </summary>
    /// <param name="context">Information on what was pushed by the player</param>
    internal void OnMove(CallbackContext context)
    {
        //Will not do anything if the window is not focused
        if (!Application.isFocused)
        {
            return;
        }

        m_InputDirection = context.canceled ? Vector3.zero : (Vector3)context.ReadValue <Vector2>();
    }
Exemplo n.º 22
0
 public void SwitchCombatMode(CallbackContext context)
 {
     if (context.ReadValueAsButton() == true && context.performed == false)
     {
         if (hasGun)
         {
             ChangeCombatMode(!combatController.IsRanged);
         }
     }
 }
Exemplo n.º 23
0
 public void DoSwing(CallbackContext ctx)
 {
     switch (ctx.phase)
     {
     case InputActionPhase.Performed:
     case InputActionPhase.Canceled:
         rawSwing = -ctx.ReadValue <float>();
         break;
     }
 }
Exemplo n.º 24
0
 public void DoToggleLight(CallbackContext ctx)
 {
     switch (ctx.phase)
     {
     case InputActionPhase.Performed:
         lightEnabled = !lightEnabled;
         lantern.gameObject.SetActive(lightEnabled);
         break;
     }
 }
Exemplo n.º 25
0
    /// <summary>
    /// 打开用户详情
    /// </summary>
    /// <param name="callback"></param>
    public void HandleForUserDetails(CallbackContext callback)
    {
        if (!isActiveAndEnabled)
        {
            return;
        }
        UIGameUserDetails uiGameUserDetails = UIHandler.Instance.OpenUIAndCloseOther <UIGameUserDetails>(UIEnum.GameUserDetails);

        uiGameUserDetails.ui_ViewSynthesis.SetDataType(ItemsSynthesisTypeEnum.Self);
    }
Exemplo n.º 26
0
    public void OnLook(CallbackContext context)
    {
        if (movement == null)
        {
            return;
        }
        var look = context.ReadValue <Vector2>();

        mouse.SetLook(look);
    }
Exemplo n.º 27
0
    public void OnMove(CallbackContext context)
    {
        if (movement == null)
        {
            return;
        }
        var move = context.ReadValue <Vector2>();

        movement.SetMovement(move);
    }
        private void MovePerformed(CallbackContext context)
        {
            var raw = context.ReadValue <Vector2>();

            var m = InputFiltering.ApplyDeadzone(raw, innerDeadzone, outerDeadzone);
            var h = InputFiltering.ApplyDeadzone(raw.x0(), innerDeadzone, outerDeadzone);

            Movement           = m.normalized;
            MovementHorizontal = h.normalized;
        }
Exemplo n.º 29
0
 private void OnJoinGame(CallbackContext ctx)
 {
     if (InputDeviceManager.AddPlayer(ctx.control.device))
     {
         int playerNumber = InputDeviceManager.GetPlayerNumber(ctx.control.device);
         playerProps[playerNumber - 1].SetActive(true);
         playerTexts[playerNumber - 1].SetActive(false);
         Debug.Log("Player " + playerNumber + " joined game");
     }
 }
Exemplo n.º 30
0
 private void OnMiddleMouseClick(CallbackContext ctx)
 {
     if (ctx.ReadValueAsButton())
     {
         IsToolBarSelected = !IsToolBarSelected;
         toolController.selectedTool?.ShowToolInfo();
         ShowToolBarHighlight();
         //StartCoroutine(ResetColor(img));
     }
 }
Exemplo n.º 31
0
 public void OnVisible(CallbackContext context)
 {
     if (game_state == 1)
     {
         if (player != null)
         {
             player.SetVisible(context.ReadValue <float>());
         }
     }
 }
Exemplo n.º 32
0
 public void DoRun(CallbackContext ctx)
 {
     switch (ctx.phase)
     {
     case InputActionPhase.Performed:
     case InputActionPhase.Canceled:
         running = ctx.ReadValueAsButton();
         break;
     }
 }
 public void ActionBoundToDefaultSyncContext_Invoked_Executes()
 {
     using (CallbackContext context = new CallbackContext())
     using (ManualResetEvent evt = new ManualResetEvent(false))
     {
         var action = context.Bind(() => { evt.Set(); }, new SynchronizationContext(), false);
         action();
         bool signalled = evt.WaitOne(100);
         Assert.IsTrue(signalled, "Action did not run");
     }
 }
 internal bool Invoke(string hostName, ServicePoint servicePoint, X509Certificate certificate, WebRequest request, X509Chain chain, SslPolicyErrors sslPolicyErrors)
 {
     PolicyWrapper policyWrapper = new PolicyWrapper(this.m_CertificatePolicy, servicePoint, request);
     if (this.m_Context == null)
     {
         return policyWrapper.CheckErrors(hostName, certificate, chain, sslPolicyErrors);
     }
     ExecutionContext executionContext = this.m_Context.CreateCopy();
     CallbackContext state = new CallbackContext(policyWrapper, hostName, certificate, chain, sslPolicyErrors);
     ExecutionContext.Run(executionContext, new ContextCallback(this.Callback), state);
     return state.result;
 }
        public void Action_InvokedAfterContextDispose_DoesNotExecute()
        {
            bool sawAction = false;
            Action action = null;

            using (CallbackContext context = new CallbackContext())
            {
                action = context.Bind(() => { sawAction = true; });
            }

            action();
            Assert.IsFalse(sawAction, "Invalid action did execute");
        }
        public void BoundAsyncAction_Invoked_ExecutesSynchronized()
        {
            int sawActionThread = Thread.CurrentThread.ManagedThreadId;

            using (CallbackContext context = new CallbackContext())
            using (ActionThread thread = new ActionThread())
            {
                thread.Start();

                // Capture the thread's SynchronizationContext
                SynchronizationContext actionThreadSyncContext = thread.DoGet(() => { return SynchronizationContext.Current; });

                var action = context.AsyncBind(() => { sawActionThread = Thread.CurrentThread.ManagedThreadId; }, actionThreadSyncContext);
                action();
                thread.Join();

                Assert.AreEqual(thread.ManagedThreadId, sawActionThread, "Bound action was not synchronized");
            }
        }
        public void BoundAsyncAction_Invoked_DecrementsSyncContextOperationCount()
        {
            bool sawOperationCompleted = false;

            using (CallbackContext context = new CallbackContext())
            using (ActionThread thread = new ActionThread())
            {
                thread.Start();

                // Capture the thread's SynchronizationContext
                SynchronizationContext actionThreadSyncContext = thread.DoGet(() => { return SynchronizationContext.Current; });

                var syncContext = new LoggingSynchronizationContext(actionThreadSyncContext)
                {
                    OnOperationCompleted = () => { sawOperationCompleted = true; }
                };

                var action = context.AsyncBind(() => { }, syncContext, false);
                action();
                thread.Join();

                Assert.IsFalse(sawOperationCompleted, "Context decremented operation count");
            }
        }
        public void InvalidBoundSyncedFunc_Invoked_DoesNotExecute()
        {
            int sawActionThread = Thread.CurrentThread.ManagedThreadId;

            using (CallbackContext context = new CallbackContext())
            using (ActionThread thread = new ActionThread())
            {
                thread.Start();

                // Capture the thread's SynchronizationContext and signal this thread when it's captured.
                SynchronizationContext actionThreadSyncContext = thread.DoGet(() => { return SynchronizationContext.Current; });

                var action = context.Bind(() => { sawActionThread = Thread.CurrentThread.ManagedThreadId; return 13; }, actionThreadSyncContext, false);
                context.Reset();
                int result = action();

                Assert.AreEqual(Thread.CurrentThread.ManagedThreadId, sawActionThread, "Invalid action should not run");
            }
        }
 public void CallbackContext_AfterInvokingInvalidAction_IsInvalid()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var action = context.Bind(() => { });
         context.Reset();
         action();
         Assert.IsTrue(context.Invalidated, "Bound action should be invalid");
     }
 }
        internal bool Invoke(string hostName,
                             ServicePoint servicePoint,
                             X509Certificate certificate,
                             WebRequest request,
                             X509Chain chain,
                             SslPolicyErrors sslPolicyErrors)
        {
            PolicyWrapper policyWrapper = new PolicyWrapper(m_CertificatePolicy,
                                                            servicePoint,
                                                            (WebRequest) request);

            if (m_Context == null)
            {
                return policyWrapper.CheckErrors(hostName,
                                                 certificate,
                                                 chain,
                                                 sslPolicyErrors);
            }
            else
            {
                ExecutionContext execContext = m_Context.CreateCopy();
                CallbackContext callbackContext = new CallbackContext(policyWrapper,
                                                                      hostName,
                                                                      certificate,
                                                                      chain,
                                                                      sslPolicyErrors);
                ExecutionContext.Run(execContext, Callback, callbackContext);
                return callbackContext.result;
            }
        }
        public void ValidAction_Invoked_Executes()
        {
            bool sawAction = false;

            using (CallbackContext context = new CallbackContext())
            {
                var action = context.Bind(() => { sawAction = true; });
                action();
                Assert.IsTrue(sawAction, "Bound action did not execute");
            }
        }
        public void InvalidFunc_Invoked_DoesNotExecute()
        {
            bool sawAction = false;

            using (CallbackContext context = new CallbackContext())
            {
                var action = context.Bind(() => { sawAction = true;  return 13; });
                context.Reset();
                int result = action();
                Assert.IsFalse(sawAction, "Invalid action did execute");
            }
        }
 public void CallbackContext_WithInvokedFunc_IsNotInvalid()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var action = context.Bind(() => { return 13; });
         int result = action();
         Assert.IsFalse(context.Invalidated, "Bound action should be valid");
     }
 }
 public void CallbackContext_WithInvokedAction_IsNotInvalid()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var action = context.Bind(() => { });
         action();
         Assert.IsFalse(context.Invalidated, "Bound action should be valid");
     }
 }
        public void CallbackContext_Reset_InvalidatesAllFuncs()
        {
            bool sawAction1 = false;
            bool sawAction2 = false;

            using (CallbackContext context = new CallbackContext())
            {
                var action1 = context.Bind(() => { sawAction1 = true; return 13; });
                var action2 = context.Bind(() => { sawAction2 = true; return 17; });

                context.Reset();
                int result1 = action1();
                int result2 = action2();

                Assert.IsFalse(sawAction1, "Invalid action did execute");
                Assert.IsFalse(sawAction2, "Invalid action did execute");
            }
        }
 public void CallbackContext_ResetAfterBindingFunc_IsInvalid()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var action = context.Bind(() => { return 13; });
         context.Reset();
         Assert.IsTrue(context.Invalidated, "Bound action should be invalid");
     }
 }
 public void CallbackContext_BindingFuncWithDefaultSyncContext_ThrowsInvalidOperationException()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var action = context.Bind(() => { return 13; }, new SynchronizationContext());
     }
 }
        public void InvalidBoundSyncedFunc_Invoked_DoesSync()
        {
            bool sawSync = false;

            using (CallbackContext context = new CallbackContext())
            using (ActionThread thread = new ActionThread())
            {
                thread.Start();

                // Capture the thread's SynchronizationContext and signal this thread when it's captured.
                SynchronizationContext actionThreadSyncContext = thread.DoGet(() => { return SynchronizationContext.Current; });

                var syncContext = new LoggingSynchronizationContext(actionThreadSyncContext)
                {
                    OnPost = () => { sawSync = true; },
                    OnSend = () => { sawSync = true; }
                };

                var action = context.Bind(() => { return 13; }, syncContext, false);
                context.Reset();
                int result = action();

                Assert.IsTrue(sawSync, "Context did not use SyncContext for sync");
            }
        }
        public void InvalidBoundSyncedFunc_Invoked_ReturnsDefault()
        {
            using (CallbackContext context = new CallbackContext())
            using (ActionThread thread = new ActionThread())
            {
                thread.Start();

                // Capture the thread's SynchronizationContext and signal this thread when it's captured.
                SynchronizationContext actionThreadSyncContext = thread.DoGet(() => { return SynchronizationContext.Current; });

                var action = context.Bind(() => { return 13; }, actionThreadSyncContext, false);
                context.Reset();
                int result = action();

                Assert.AreEqual(0, result, "Invalid Func returned a non-default value");
            }
        }
        public void Func_InvokedAfterContextDispose_DoesNotExecute()
        {
            bool sawAction = false;
            Func<int> action = null;

            using (CallbackContext context = new CallbackContext())
            {
                action = context.Bind(() => { sawAction = true; return 13; });
            }

            int result = action();
            Assert.IsFalse(sawAction, "Invalid action did execute");
        }
 public void InvalidFunc_Invoked_ReturnsDefault()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var action = context.Bind(() => { return 13; });
         context.Reset();
         int result = action();
         Assert.AreEqual(default(int), result, "Invalid func had a non-default return value");
     }
 }
        public void Func_InvokedAfterContextDispose_ReturnsDefault()
        {
            Func<int> action = null;

            using (CallbackContext context = new CallbackContext())
            {
                action = context.Bind(() => { return 13; });
            }

            int result = action();
            Assert.AreEqual(0, result, "Invalid func had a non-default return value");
        }
        public void BoundSyncedAction_Invoked_UsesSyncContext()
        {
            bool sawSync = false;

            using (CallbackContext context = new CallbackContext())
            using (ActionThread thread = new ActionThread())
            {
                thread.Start();

                // Capture the thread's SynchronizationContext
                SynchronizationContext actionThreadSyncContext = thread.DoGet(() => { return SynchronizationContext.Current; });

                var syncContext = new LoggingSynchronizationContext(actionThreadSyncContext)
                {
                    OnPost = () => { sawSync = true; },
                    OnSend = () => { sawSync = true; }
                };

                var action = context.Bind(() => { }, syncContext, false);
                action();

                Assert.IsTrue(sawSync, "Context did not use SyncContext for sync");
            }
        }
        public void InvalidBoundObjectsyncedFunc_Invoked_DoesNotExecute()
        {
            int sawActionThread = Thread.CurrentThread.ManagedThreadId;

            using (CallbackContext context = new CallbackContext())
            {
                var syncObject = new FakeFuncSynchronizingObject(true);
                var action = context.Bind(() => { sawActionThread = Thread.CurrentThread.ManagedThreadId; return 13; }, syncObject);
                context.Reset();
                int result = action();
                Assert.AreEqual(Thread.CurrentThread.ManagedThreadId, sawActionThread, "Bound action was executed");
            }
        }
 internal bool Invoke(object request,
                      X509Certificate certificate,
                      X509Chain chain,
                      SslPolicyErrors sslPolicyErrors)
 {
     if (m_Context == null)
     {
         return m_ValidationCallback(request, certificate, chain, sslPolicyErrors);
     }
     else
     {
         ExecutionContext execContext = m_Context.CreateCopy();
         CallbackContext callbackContext = new CallbackContext(request,
                                                               certificate,
                                                               chain,
                                                               sslPolicyErrors);
         ExecutionContext.Run(execContext, Callback, callbackContext);
         return callbackContext.result;
     }
 }
 public void InvalidBoundObjectsyncedFunc_Invoked_ReturnsDefault()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var syncObject = new FakeFuncSynchronizingObject(true);
         var action = context.Bind(() => { return 13; }, syncObject);
         context.Reset();
         int result = action();
         Assert.AreEqual(0, result, "Invalid func returned non-default value");
     }
 }
Exemplo n.º 57
0
 private void TriggerCallback(CallbackContext context)
 {
     context.Error = _lastWriteError;
     ThreadPool.QueueUserWorkItem(obj =>
     {
         var c = (CallbackContext)obj;
         c.Callback(c.Error, c.State);
     }, context);
 }
 public void InvalidBoundObjectsyncedFunc_Invoked_SynchronizesWithSyncObject()
 {
     using (CallbackContext context = new CallbackContext())
     {
         var syncObject = new FakeFuncSynchronizingObject(true);
         var action = context.Bind(() => { return 13; }, syncObject);
         context.Reset();
         int result = action();
         Assert.IsTrue(syncObject.sawInvoke, "Bound action did not run through synchronizing object");
     }
 }
Exemplo n.º 59
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Timer"/> class, binding to <see cref="SynchronizationContext.Current">SynchronizationContext.Current</see>.
        /// </summary>
        /// <example>The following code sample demonstrates how to construct a single-shot Timer, start it, and handle the <see cref="Elapsed"/> event:
        /// <code source="..\..\Source\Examples\DocumentationExamples\Timer\SingleShot.cs"/>
        /// </example>
        public Timer()
        {
            // Capture the synchronization context
            synchronizationContext = SynchronizationContext.Current;
            if (synchronizationContext == null)
            {
                synchronizationContext = new SynchronizationContext();
            }

            // Verify that the synchronization context is synchronized
            SynchronizationContextRegister.Verify(synchronizationContext.GetType(), SynchronizationContextProperties.Synchronized);

            // Create the context for timer callbacks
            context = new CallbackContext();
        }
        public void BoundSyncedFunc_Invoked_IncrementsSyncContextOperationCount()
        {
            bool sawOperationStarted = false;

            using (CallbackContext context = new CallbackContext())
            using (ActionThread thread = new ActionThread())
            {
                thread.Start();

                // Capture the thread's SynchronizationContext
                SynchronizationContext actionThreadSyncContext = thread.DoGet(() => { return SynchronizationContext.Current; });

                var syncContext = new LoggingSynchronizationContext(actionThreadSyncContext)
                {
                    OnOperationStarted = () => { sawOperationStarted = true; }
                };

                var action = context.Bind(() => { return 13; }, syncContext, false);
                int result = action();

                Assert.IsFalse(sawOperationStarted, "Context incremented operation count");
            }
        }