本文整理汇总了C#中AsyncResult.SetComplete方法的典型用法代码示例。如果您正苦于以下问题:C# AsyncResult.SetComplete方法的具体用法?C# AsyncResult.SetComplete怎么用?C# AsyncResult.SetComplete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsyncResult
的用法示例。
在下文中一共展示了AsyncResult.SetComplete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenCompleted_ThenESetsResult
public void WhenCompleted_ThenESetsResult()
{
var result = new AsyncResult<object>(null, null);
result.SetComplete(this, true);
Assert.AreSame(this, result.Result);
}
示例2: WhenCompletedSynchronouslyWithNoCallback_ThenUpdatesCompletionStatus
public void WhenCompletedSynchronouslyWithNoCallback_ThenUpdatesCompletionStatus()
{
var result = new AsyncResult<object>(null, null);
result.SetComplete(null, true);
Assert.IsTrue(result.IsCompleted);
Assert.IsTrue(result.CompletedSynchronously);
}
示例3: WhenCompleted_ThenExecutesCallback
public void WhenCompleted_ThenExecutesCallback()
{
bool executed = false;
var result = new AsyncResult<object>(ar => executed = true, null);
result.SetComplete(null, true);
Assert.IsTrue(executed);
}
示例4: BeginGetEmailDocuments
public IAsyncResult BeginGetEmailDocuments(AsyncCallback callback, object userState)
{
var asyncResult = new AsyncResult<IEnumerable<EmailDocument>>(callback, userState);
ThreadPool.QueueUserWorkItem(
o =>
{
asyncResult.SetComplete(new ReadOnlyCollection<EmailDocument>(this.emailDocuments), false);
});
return asyncResult;
}
示例5: BeginGetContacts
public IAsyncResult BeginGetContacts(AsyncCallback callback, object userState)
{
var asyncResult = new AsyncResult<IEnumerable<Contact>>(callback, userState);
ThreadPool.QueueUserWorkItem(
o =>
{
asyncResult.SetComplete(CreateContacts(), false);
});
return asyncResult;
}
示例6: BeginSubmitQuestionnaire
public IAsyncResult BeginSubmitQuestionnaire(Questionnaire questionnaire, AsyncCallback callback, object userState)
{
var asyncResult = new AsyncResult<object>(callback, userState);
ThreadPool.QueueUserWorkItem(
o =>
{
// simulated processing time
Thread.Sleep(2000);
if (!FailOnSubmit)
{
asyncResult.SetComplete((object)null, false);
}
else
{
asyncResult.SetComplete(new InvalidOperationException("Not authorized"), false);
}
});
return asyncResult;
}
示例7: BeginGetQuestionnaireTemplateSummary
public IAsyncResult BeginGetQuestionnaireTemplateSummary(QuestionnaireTemplate questionnaireTemplate, AsyncCallback callback, object userState)
{
var asyncResult = new AsyncResult<QuestionnaireTemplateSummary>(callback, userState);
ThreadPool.QueueUserWorkItem(
o =>
{
Thread.Sleep(1500);
asyncResult.SetComplete(CreateQuestionnaireTemplateSummary(questionnaireTemplate), false);
});
return asyncResult;
}
示例8: BeginSendEmailDocument
public IAsyncResult BeginSendEmailDocument(EmailDocument email, AsyncCallback callback, object userState)
{
var asyncResult = new AsyncResult<object>(callback, userState);
ThreadPool.QueueUserWorkItem(
o =>
{
Thread.Sleep(500);
asyncResult.SetComplete(null, false);
});
return asyncResult;
}
示例9: BeginSubmitResponses
public IAsyncResult BeginSubmitResponses(Questionnaire questionnaire, AsyncCallback callback, object asyncState)
{
var result = new AsyncResult<object>(callback, asyncState);
ThreadPool.QueueUserWorkItem(
state =>
{
DoSubmitResponses(questionnaire);
result.SetComplete(null, false);
});
return result;
}
示例10: BeginGetQuestionnaire
public IAsyncResult BeginGetQuestionnaire(AsyncCallback callback, object asyncState)
{
AsyncResult<Questionnaire> asyncResult = new AsyncResult<Questionnaire>(callback, asyncState);
ThreadPool.QueueUserWorkItem(
state =>
{
var questionnaire = DoGetQuestionnaire();
asyncResult.SetComplete(questionnaire, false);
});
return asyncResult;
}
示例11: BeginFindAll
public IAsyncResult BeginFindAll(AsyncCallback callback, object asyncState)
{
AsyncResult<Users> asyncResult = new AsyncResult<Users>(callback, asyncState);
ThreadPool.QueueUserWorkItem(
state =>
{
var users = this.FindAllUsersAsync();
asyncResult.SetComplete(users, false);
});
return asyncResult;
}
示例12: WhenInvokingEndBeforeCompletion_ThenBlocksUntilComplete
public void WhenInvokingEndBeforeCompletion_ThenBlocksUntilComplete()
{
var result = new AsyncResult<object>(null, null);
bool pre = false;
bool post = false;
ThreadPool.QueueUserWorkItem(
o =>
{
pre = true;
AsyncResult<object>.End(result);
post = true;
});
EnqueueConditional(() => pre);
EnqueueCallback(
() =>
{
Assert.IsFalse(post);
result.SetComplete(null, false);
});
EnqueueConditional(() => pre);
EnqueueTestComplete();
}
示例13: WhenInvokingEndForTheWrongAsyncResultType_ThenThrowsException
public void WhenInvokingEndForTheWrongAsyncResultType_ThenThrowsException()
{
var result = new AsyncResult<object>(null, null);
result.SetComplete(null, false);
try
{
AsyncResult<int>.End(result);
Assert.Fail();
}
catch (ArgumentException)
{
}
}
示例14: ProceedGetQuestionnaireTemplateSummary
public void ProceedGetQuestionnaireTemplateSummary(AsyncResult<QuestionnaireTemplateSummary> result, QuestionnaireTemplateSummary questionnaireTemplateSummary)
{
result.SetComplete(questionnaireTemplateSummary, false);
}
示例15: ProceedSubmitResponses
public void ProceedSubmitResponses(AsyncResult<object> result)
{
result.SetComplete(null, false);
}