當前位置: 首頁>>代碼示例>>C#>>正文


C# AsyncOperation.SetResult方法代碼示例

本文整理匯總了C#中AsyncOperation.SetResult方法的典型用法代碼示例。如果您正苦於以下問題:C# AsyncOperation.SetResult方法的具體用法?C# AsyncOperation.SetResult怎麽用?C# AsyncOperation.SetResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AsyncOperation的用法示例。


在下文中一共展示了AsyncOperation.SetResult方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ContinueWithActionInterfaceTest

        public void ContinueWithActionInterfaceTest()
        {
            var operation = new AsyncOperation<bool>();
            IOperationResult<bool> operationResult = OperationResult.CreateResult(OperationType.PageNavigation, this, true,
                DataContext.Empty);

            bool isInvoked = false;
            var continuationAction = new ActionContinuationMock
            {
                Invoke = result =>
                {
                    result.ShouldEqual(operationResult);
                    isInvoked = true;
                }
            };

            operation.ContinueWith(continuationAction);
            isInvoked.ShouldBeFalse();
            operation.SetResult(operationResult);
            isInvoked.ShouldBeTrue();

            isInvoked = false;
            operation.ContinueWith(continuationAction);
            isInvoked.ShouldBeTrue();
        }
開發者ID:sami1971,項目名稱:MugenMvvmToolkit,代碼行數:25,代碼來源:AsyncOperationTest.cs

示例2: ResultTest

 public void ResultTest()
 {
     var operation = new AsyncOperation<bool>();
     IOperationResult<bool> operationResult = OperationResult.CreateResult(OperationType.PageNavigation, this, true,
         DataContext.Empty);
     operation.SetResult(operationResult);
     operation.Result.ShouldEqual(operationResult);
 }
開發者ID:sami1971,項目名稱:MugenMvvmToolkit,代碼行數:8,代碼來源:AsyncOperationTest.cs

示例3: IsCompletedTest

 public void IsCompletedTest()
 {
     var operation = new AsyncOperation<bool>();
     operation.IsCompleted.ShouldBeFalse();
     operation.SetResult(OperationResult.CreateResult(OperationType.PageNavigation, this, true,
         DataContext.Empty));
     operation.IsCompleted.ShouldBeTrue();
 }
開發者ID:sami1971,項目名稱:MugenMvvmToolkit,代碼行數:8,代碼來源:AsyncOperationTest.cs

示例4: ContinueWithActionInterfaceContinuationTest

        public void ContinueWithActionInterfaceContinuationTest()
        {
            var operation = new AsyncOperation<bool>();
            IOperationResult<bool> operationResult = OperationResult
                .CreateResult(OperationType.PageNavigation, this, true, DataContext.Empty);
            var exception = new TestException();
            var continuationAction = new ActionContinuationMock
            {
                Invoke = result =>
                {
                    throw exception;
                }
            };

            var continueWith = operation.ContinueWith(continuationAction);
            continueWith.IsCompleted.ShouldBeFalse();
            operation.SetResult(operationResult);

            continueWith.IsCompleted.ShouldBeTrue();
            continueWith.Result.IsFaulted.ShouldBeTrue();
            continueWith.Result.Exception.ShouldEqual(exception);
        }
開發者ID:sami1971,項目名稱:MugenMvvmToolkit,代碼行數:22,代碼來源:AsyncOperationTest.cs

示例5: OperationShouldUseDelegateToCreateMethodChain

        public void OperationShouldUseDelegateToCreateMethodChain()
        {
            var operation = new AsyncOperation<bool>();
            bool isFuncInvoked = false;
            bool isFuncGenericInvoked = false;
            bool isActionGenericInvoked = false;
            bool isActionInvoked = false;

            var func = new Func<IOperationResult, object>(op =>
            {
                isFuncInvoked = true;
                return operation;
            });
            var funcGeneric = new Func<IOperationResult<object>, bool>(o =>
            {
                isFuncGenericInvoked = true;
                o.Result.ShouldEqual(operation);
                return true;
            });
            var actionGeneric = new Action<IOperationResult<bool>>(op =>
            {
                isActionGenericInvoked = true;
                op.Result.ShouldBeTrue();
            });
            var action = new Action<IOperationResult>(op =>
            {
                isActionInvoked = true;
            });

            operation.ContinueWith(continuationFunction: func)
                     .ContinueWith(funcGeneric)
                     .ContinueWith(actionGeneric)
                     .ContinueWith(action);

            operation.SetResult(OperationResult.CreateResult(OperationType.PageNavigation, this, true));

            isFuncInvoked.ShouldBeTrue();
            isFuncGenericInvoked.ShouldBeTrue();
            isActionGenericInvoked.ShouldBeTrue();
            isActionInvoked.ShouldBeTrue();
        }
開發者ID:sami1971,項目名稱:MugenMvvmToolkit,代碼行數:41,代碼來源:AsyncOperationTest.cs

示例6: ContinueWithFunctionInterfaceGenericTest

        public void ContinueWithFunctionInterfaceGenericTest()
        {
            var operation = new AsyncOperation<bool>();
            IOperationResult<bool> operationResult = OperationResult.CreateResult(OperationType.PageNavigation, this, true,
                DataContext.Empty);

            var funcResult = new object();
            var continuationFunction = new FunctionContinuationMock<bool, object>
            {
                Invoke = result =>
                {
                    result.ShouldEqual(operationResult);
                    return funcResult;
                }
            };

            var op = operation.ContinueWith(continuationFunction);
            op.IsCompleted.ShouldBeFalse();
            operation.SetResult(operationResult);
            op.Result.Result.ShouldEqual(funcResult);

            operation.ContinueWith(continuationFunction);
            op.Result.Result.ShouldEqual(funcResult);
        }
開發者ID:sami1971,項目名稱:MugenMvvmToolkit,代碼行數:24,代碼來源:AsyncOperationTest.cs


注:本文中的AsyncOperation.SetResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。