This commit is contained in:
BlubbFish 2018-05-29 16:15:17 +00:00
parent 448b916ef1
commit fd4373645c
2 changed files with 53 additions and 128 deletions

View File

@ -1,136 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
using System.Threading;
namespace Testconsole
{
/*class Program
{
private class bla
{
public string Rb_charge_nr;
public string Rb_mat_nr;
public string Rb_kg_rohs;
public string Rb_eox_kg;
public string Rb_koh_kg;
public string Rb_milchs_kg;
public string Rb_essig_kg;
}
static void Main(string[] args)
{
namespace Testconsole {
class Program {
private Boolean RunningProcess = true;
private System.Threading.Thread sig_thread;
string strLine = "asdads,asdasd,asd,asd,asd,ads,a,sd,a,sd,as,d,asd,a,sd";
bla a = new bla();
try
{
string[] split = strLine.Split(',');
a.Rb_charge_nr = split[0];
a.Rb_mat_nr = a.Rb_charge_nr.Substring(3, 3);
a.Rb_kg_rohs = split[1];
a.Rb_eox_kg = split[2];
a.Rb_koh_kg = split[3];
a.Rb_milchs_kg = split[4];
a.Rb_essig_kg = split[5];
}
}
}*/
// This example demonstrates the Console.Beep(Int32, Int32) method
public static void Main() => new Program();
Program() {
Console.WriteLine("Start");
this.WaitForShutdown();
Console.WriteLine("Shutdown");
Console.ReadLine();
}
class Program
{
public static void Main()
{
// Declare the first few notes of the song, "Mary Had A Little Lamb".
Note[] Mary =
{
new Note(Tone.B, Duration.QUARTER),
new Note(Tone.A, Duration.QUARTER),
new Note(Tone.GbelowC, Duration.QUARTER),
new Note(Tone.A, Duration.QUARTER),
new Note(Tone.B, Duration.QUARTER),
new Note(Tone.B, Duration.QUARTER),
new Note(Tone.B, Duration.HALF),
new Note(Tone.A, Duration.QUARTER),
new Note(Tone.A, Duration.QUARTER),
new Note(Tone.A, Duration.HALF),
new Note(Tone.B, Duration.QUARTER),
new Note(Tone.D, Duration.QUARTER),
new Note(Tone.D, Duration.HALF)
private void WaitForShutdown() {
this.sig_thread = new System.Threading.Thread(delegate () {
Console.WriteLine("Mono: Create thread");
Mono.Unix.UnixSignal[] signals = new Mono.Unix.UnixSignal[] {
new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGTERM),
new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGINT)
};
// Play the song
Play(Mary);
}
// Play the notes in a song.
protected static void Play(Note[] tune)
{
foreach (Note n in tune)
{
if (n.NoteTone == Tone.REST)
Thread.Sleep((int)n.NoteDuration);
else
Console.Beep((int)n.NoteTone, (int)n.NoteDuration);
Console.WriteLine("Mono: Set Signals");
while (this.RunningProcess) {
Console.WriteLine("Mono: Wait for Signal");
Int32 i = Mono.Unix.UnixSignal.WaitAny(signals, -1);
Console.WriteLine("Mono: Signal Recieved: "+i);
this.RunningProcess = false;
}
});
if (Type.GetType("Mono.Runtime") != null) {
this.sig_thread.Start();
} else {
Console.CancelKeyPress += new ConsoleCancelEventHandler(this.SetupShutdown);
}
Console.WriteLine("Windows: Create Handler");
Console.WriteLine("Wait");
while (this.RunningProcess) {
System.Threading.Thread.Sleep(100);
}
Console.WriteLine("After Wait");
}
// Define the frequencies of notes in an octave, as well as
// silence (rest).
protected enum Tone
{
REST = 0,
GbelowC = 196,
A = 220,
Asharp = 233,
B = 247,
C = 262,
Csharp = 277,
D = 294,
Dsharp = 311,
E = 330,
F = 349,
Fsharp = 370,
G = 392,
Gsharp = 415,
}
// Define the duration of a note in units of milliseconds.
protected enum Duration
{
WHOLE = 1600,
HALF = WHOLE/2,
QUARTER = HALF/2,
EIGHTH = QUARTER/2,
SIXTEENTH = EIGHTH/2,
}
// Define a note as a frequency (tone) and the amount of
// time (duration) the note plays.
protected struct Note
{
Tone toneVal;
Duration durVal;
// Define a constructor to create a specific note.
public Note(Tone frequency, Duration time)
{
toneVal = frequency;
durVal = time;
}
// Define properties to return the note's tone and duration.
public Tone NoteTone { get{ return toneVal; } }
public Duration NoteDuration { get{ return durVal; } }
private void SetupShutdown(Object sender, ConsoleCancelEventArgs e) {
e.Cancel = true;
Console.WriteLine("Windows get Signal");
this.RunningProcess = false;
}
}
/*
This example produces the following results:
This example plays the first few notes of "Mary Had A Little Lamb"
through the console speaker.
*/
}
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -9,8 +9,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Testconsole</RootNamespace>
<AssemblyName>Testconsole</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -45,9 +48,16 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Mono.Posix.5.4.0.201\build\net45\Mono.Posix.targets" Condition="Exists('..\packages\Mono.Posix.5.4.0.201\build\net45\Mono.Posix.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Mono.Posix.5.4.0.201\build\net45\Mono.Posix.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Mono.Posix.5.4.0.201\build\net45\Mono.Posix.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">