Files
Umbraco-CMS/tests/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/ThreadingTaskImmutable.cs
Paul Johnson 00133e880d Move test projects from src/ to tests/ (#11357)
* Update gitignore

* Move csproj

* Update project references

* Update solutions

* Update build scripts

* Tests used to share editorconfig with projects in src

* Fix broken tests.

* Stop copying around .editorconfig

merged root one with linting

* csharp_style_expression_bodied -> suggestion

* Move StyleCop rulesets to matching directories and update shared build properties

* Remove legacy build files, update NuGet.cofig and solution files

* Restore myget source

* Clean up .gitignore

* Update .gitignore

* Move new test classes to tests after merge

* Gitignore + nuget config

* Move new test

Co-authored-by: Ronald Barendse <ronald@barend.se>
2021-10-18 08:14:04 +01:00

45 lines
1.3 KiB
C#

using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Umbraco.Web.Scheduling
{
/// <summary>
/// Wraps a <see cref="Task"/> within an object that gives access to its GetAwaiter method and Status
/// property while ensuring that it cannot be modified in any way.
/// </summary>
public class ThreadingTaskImmutable
{
private readonly Task _task;
/// <summary>
/// Initializes a new instance of the <see cref="ThreadingTaskImmutable"/> class with a Task.
/// </summary>
/// <param name="task">The task.</param>
public ThreadingTaskImmutable(Task task)
{
if (task == null)
throw new ArgumentNullException("task");
_task = task;
}
/// <summary>
/// Gets an awaiter used to await the task.
/// </summary>
/// <returns>An awaiter instance.</returns>
public TaskAwaiter GetAwaiter()
{
return _task.GetAwaiter();
}
/// <summary>
/// Gets the TaskStatus of the task.
/// </summary>
/// <returns>The current TaskStatus of the task.</returns>
public TaskStatus Status
{
get { return _task.Status; }
}
}
}