Xamarin Public Jenkins (auto-signing) e79aa3c0ed Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
2016-08-03 10:59:49 +00:00

55 lines
1.6 KiB
C#

//------------------------------------------------------------------------------
// <copyright file="TaskWrapperAsyncResult.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* Wraps a Task class, optionally overriding the State object (since the Task Asynchronous Pattern doesn't normally use them).
*
* Copyright (c) 2010 Microsoft Corporation
*/
namespace System.Web {
using System;
using System.Threading;
using System.Threading.Tasks;
internal sealed class TaskWrapperAsyncResult : IAsyncResult {
private bool _forceCompletedSynchronously;
internal TaskWrapperAsyncResult(Task task, object asyncState) {
Task = task;
AsyncState = asyncState;
}
public object AsyncState {
get;
private set;
}
public WaitHandle AsyncWaitHandle {
get { return ((IAsyncResult)Task).AsyncWaitHandle; }
}
public bool CompletedSynchronously {
get { return _forceCompletedSynchronously || ((IAsyncResult)Task).CompletedSynchronously; }
}
public bool IsCompleted {
get { return ((IAsyncResult)Task).IsCompleted; }
}
internal Task Task {
get;
private set;
}
internal void ForceCompletedSynchronously() {
_forceCompletedSynchronously = true;
}
}
}