Task-based Asynchronous Pattern (TAP)
CREATED BY: | Latency McLaughlin |
UPDATED: | 2/1/2018 |
FRAMEWORK: | .NETFramework 4.5 - 4.7.1, .NETStandard2.0, .NETCoreApp2.0 (Latest) |
LANGUAGE: | C# (v7.0) |
OUTPUT TYPE: | Console Application + API |
SUPPORTS: | Visual Studio 2017, 2015, 2013, 2012, 2010, 2008 |
TAGS: | .NET, NuGet, MyGet, API, C#, NUnit, Visual Studio |
STATUS: | |
LICENSE: | |
CHAT: | |
VERSION: |
This article introduces an API which generates artifacts asynchronously; supporting deadlock protection, timeout, cancellation requests, and checkpointing.
ResourceGenerator is compiled as a library packaged for the MyGet marketplace. The project itself, supplies an application driver, and test suite, and source code.
This API has several benefits, such as:
-- ResourceGenerator benefits.
- Supports centralized versioning.
- Reusable code.
- Decrease download time.
- Optomizes performance of asynchronous code.
- Packaged in NuGet format.
- Reduce boilerplate installation and batch file code.
-
Async / Await support.
Downloads for artifact images via web request calls run in parallel based on card set. Upon collection of the entire set, post-image processing is performed and images are bundled into resource files. Each image is rescaled and fixed for 130x34 8bpp PNG which is a compresssed format replacement to Bitmap which is not supported in .NET Core. -
Cancellation Checkpointing
Threading is handled by TPL and is wrapped by ORM-Monitor which handles the scheduling and asynchronous event dispatch.
This library is to be installed from MyGet:
There are plug-ins that this project uses as dependency from NuGet that are built-in and linked into the API.
Now integrated into loader of DeckTracker.exe
ResourceGenerator.exe <path> <folder> <IsOverwriten> [msbuild]
ResourceGenerator.exe "$(SolutionDir)Resources" Tiles 0
# | Argument | Type | Description |
---|---|---|---|
1. | Path | String | Target directory to generate the resource in. |
2. | Folder | String | Folder name that is created underneat the root directory . |
3. | IsOverwriten | Boolean | Forces downloading external images via async web request calls. |
4. | (optional) DO_NOT_USE |
String | ["msbuild"] which is used for bootstrap post-build rules only. |
var tempDir = Path.GetTempPath();
var targetDir = Assembly.GetExecutingAssembly().Location;
Console.WriteLine(@"Running Resource Generator!");
ResourceGenerator.Program.Run(new []{ $"{tempDir}Resources", "Tiles", "0", "msbuild" });
Console.WriteLine($@"Sucessfully generated tiles in '{tempDir}Resources\Generated'");
Console.WriteLine($@"Copying Generated tiles from '{tempDir}Resources\Generated' to '{targetDir}Images\Tiles'");
XCopy.Run($@"{tempDir}Resources\Generated", $@"{targetDir}Images\Tiles");