forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompletedAsyncResultOfT.cs
More file actions
27 lines (23 loc) · 950 Bytes
/
Copy pathCompletedAsyncResultOfT.cs
File metadata and controls
27 lines (23 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics.Contracts;
namespace System.Web.Http.SelfHost.ServiceModel.Channels
{
internal class CompletedAsyncResult<T> : AsyncResult
{
private T data;
public CompletedAsyncResult(T data, AsyncCallback callback, object state)
: base(callback, state)
{
this.data = data;
Complete(true);
}
public static T End(IAsyncResult result)
{
Contract.Assert(result != null, "CompletedAsyncResult<T> was null.");
Contract.Assert(result.IsCompleted, "CompletedAsyncResult<T> was not completed!");
CompletedAsyncResult<T> completedResult = AsyncResult.End<CompletedAsyncResult<T>>(result);
return completedResult.data;
}
}
}