build: initial project release
All checks were successful
release / dotnet-release-workflow (push) Successful in 1m23s
All checks were successful
release / dotnet-release-workflow (push) Successful in 1m23s
This commit is contained in:
commit
48c483c568
62 changed files with 4957 additions and 0 deletions
42
src/process.dummy.app/Output.cs
Normal file
42
src/process.dummy.app/Output.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
internal sealed class Output : IDisposable
|
||||
{
|
||||
private readonly CancellationTokenSource _cts = new();
|
||||
|
||||
public Output()
|
||||
{
|
||||
Console.CancelKeyPress += Cancel;
|
||||
}
|
||||
|
||||
public StreamReader Stdin { get; } = new(Console.OpenStandardInput(), leaveOpen: false);
|
||||
|
||||
public StreamWriter Stdout { get; } = new(Console.OpenStandardOutput(), leaveOpen: false);
|
||||
|
||||
public StreamWriter Stderr { get; } = new(Console.OpenStandardError(), leaveOpen: false);
|
||||
|
||||
public CancellationToken CancellationToken => _cts.Token;
|
||||
|
||||
public static Output Connect()
|
||||
{
|
||||
return new Output();
|
||||
}
|
||||
|
||||
private void Cancel(object? sender, ConsoleCancelEventArgs args)
|
||||
{
|
||||
args.Cancel = true;
|
||||
_cts.Cancel();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Stdout.BaseStream.Flush();
|
||||
Stdout.Dispose();
|
||||
Stderr.BaseStream.Flush();
|
||||
Stderr.Dispose();
|
||||
Stdin.Dispose();
|
||||
Console.CancelKeyPress -= Cancel;
|
||||
_cts.Dispose();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue