diff --git a/ADIS_Csharp/.vs/ADIS_Csharp/DesignTimeBuild/.dtbcache.v2 b/ADIS_Csharp/.vs/ADIS_Csharp/DesignTimeBuild/.dtbcache.v2 new file mode 100644 index 0000000..8807e12 Binary files /dev/null and b/ADIS_Csharp/.vs/ADIS_Csharp/DesignTimeBuild/.dtbcache.v2 differ diff --git a/ADIS_Csharp/.vs/ADIS_Csharp/FileContentIndex/286c161a-7982-4674-b2a1-1869b3bc6a99.vsidx b/ADIS_Csharp/.vs/ADIS_Csharp/FileContentIndex/286c161a-7982-4674-b2a1-1869b3bc6a99.vsidx new file mode 100644 index 0000000..10fd578 Binary files /dev/null and b/ADIS_Csharp/.vs/ADIS_Csharp/FileContentIndex/286c161a-7982-4674-b2a1-1869b3bc6a99.vsidx differ diff --git a/ADIS_Csharp/.vs/ADIS_Csharp/FileContentIndex/5f9ad425-c299-4035-8dc3-a79d7c807dab.vsidx b/ADIS_Csharp/.vs/ADIS_Csharp/FileContentIndex/5f9ad425-c299-4035-8dc3-a79d7c807dab.vsidx new file mode 100644 index 0000000..be22184 Binary files /dev/null and b/ADIS_Csharp/.vs/ADIS_Csharp/FileContentIndex/5f9ad425-c299-4035-8dc3-a79d7c807dab.vsidx differ diff --git a/ADIS_Csharp/.vs/ADIS_Csharp/FileContentIndex/read.lock b/ADIS_Csharp/.vs/ADIS_Csharp/FileContentIndex/read.lock new file mode 100644 index 0000000..e69de29 diff --git a/ADIS_Csharp/.vs/ADIS_Csharp/v17/.futdcache.v1 b/ADIS_Csharp/.vs/ADIS_Csharp/v17/.futdcache.v1 new file mode 100644 index 0000000..cfb7d48 Binary files /dev/null and b/ADIS_Csharp/.vs/ADIS_Csharp/v17/.futdcache.v1 differ diff --git a/ADIS_Csharp/.vs/ADIS_Csharp/v17/.futdcache.v2 b/ADIS_Csharp/.vs/ADIS_Csharp/v17/.futdcache.v2 new file mode 100644 index 0000000..bcf1fc7 Binary files /dev/null and b/ADIS_Csharp/.vs/ADIS_Csharp/v17/.futdcache.v2 differ diff --git a/ADIS_Csharp/.vs/ADIS_Csharp/v17/.suo b/ADIS_Csharp/.vs/ADIS_Csharp/v17/.suo new file mode 100644 index 0000000..89c3a61 Binary files /dev/null and b/ADIS_Csharp/.vs/ADIS_Csharp/v17/.suo differ diff --git a/ADIS_Csharp/.vs/ProjectEvaluation/adis_csharp.metadata.v5.2 b/ADIS_Csharp/.vs/ProjectEvaluation/adis_csharp.metadata.v5.2 new file mode 100644 index 0000000..68680c7 Binary files /dev/null and b/ADIS_Csharp/.vs/ProjectEvaluation/adis_csharp.metadata.v5.2 differ diff --git a/ADIS_Csharp/.vs/ProjectEvaluation/adis_csharp.projects.v5.2 b/ADIS_Csharp/.vs/ProjectEvaluation/adis_csharp.projects.v5.2 new file mode 100644 index 0000000..5abe5cb Binary files /dev/null and b/ADIS_Csharp/.vs/ProjectEvaluation/adis_csharp.projects.v5.2 differ diff --git a/ADIS_Csharp/ADIS_Csharp.sln b/ADIS_Csharp/ADIS_Csharp.sln new file mode 100644 index 0000000..795d69a --- /dev/null +++ b/ADIS_Csharp/ADIS_Csharp.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32421.90 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "ConsoleApp\ConsoleApp.csproj", "{42720F37-2AAE-4B3D-AA7E-79A7C37D4C37}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {42720F37-2AAE-4B3D-AA7E-79A7C37D4C37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {42720F37-2AAE-4B3D-AA7E-79A7C37D4C37}.Debug|Any CPU.Build.0 = Debug|Any CPU + {42720F37-2AAE-4B3D-AA7E-79A7C37D4C37}.Release|Any CPU.ActiveCfg = Release|Any CPU + {42720F37-2AAE-4B3D-AA7E-79A7C37D4C37}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A5C1D40B-1119-4958-885D-1B0FF413EDE8} + EndGlobalSection +EndGlobal diff --git a/ADIS_Csharp/ConsoleApp/AdditionTask.cs b/ADIS_Csharp/ConsoleApp/AdditionTask.cs new file mode 100644 index 0000000..519ce1e --- /dev/null +++ b/ADIS_Csharp/ConsoleApp/AdditionTask.cs @@ -0,0 +1,26 @@ +namespace ConsoleApp +{ + internal class AdditionTask + { + + private int n; + private String id; + + public AdditionTask(string id, int n) + { + this.id = id; + this.n = n; + } + + public void Add() + { + long sum = 0; + for (int i = 0; i <= n; i++) + { + sum += i; + } + Console.WriteLine(id + ": SUM" + n + " -> " + sum); + } + + } +} diff --git a/ADIS_Csharp/ConsoleApp/ConsoleApp.csproj b/ADIS_Csharp/ConsoleApp/ConsoleApp.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/ADIS_Csharp/ConsoleApp/ConsoleApp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/ADIS_Csharp/ConsoleApp/Program.cs b/ADIS_Csharp/ConsoleApp/Program.cs new file mode 100644 index 0000000..942b3a2 --- /dev/null +++ b/ADIS_Csharp/ConsoleApp/Program.cs @@ -0,0 +1,170 @@ +using ConsoleApp; +#if false +class ThreadTest3 +{ + // Member variablen werden automatisch initialisiert + // lokale nicht + // Csharp compiler gibt einen Error aus, wenn die Variable nicht initialisiert wird + private bool done; + static void Main() + { + ThreadTest3 tt = new ThreadTest3(); + new Thread(tt.Go).Start(); + tt.Go(); + } + void Go() + { + if (!done) + { + // Thread.Sleep(10); ==> proviziert error + done = true; + Console.WriteLine("Done"); + } + } +} +#endif + +#if false +class ThreadTest7 +{ + + static void Main() + { + AdditionTask work1 = new AdditionTask("A", 100000000); + AdditionTask work2 = new AdditionTask("B", 100000); + AdditionTask work3 = new AdditionTask("C", 100); + Thread t1 = new Thread(work1.Add); + Thread t2 = new Thread(work2.Add); + Thread t3 = new Thread(work3.Add); + //t3.Priority = ThreadPriority.Lowest; + t1.Start(); + t2.Start(); + t3.Start(); + } + +} +#endif + +#if false +class ThreadStop1 +{ + static void Main() + { + try + { + Thread thread1 = new Thread(Go); + thread1.Start(); + } + catch (Exception ex) + { + Console.WriteLine("Exception!"); + } + } + + private static void TaskScheduler_UnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e) + { + Console.WriteLine("Exception caught"); + throw new NotImplementedException(); + } + + static void Go() + { + throw null; // NullReferenceException wird ausgelöst + Console.WriteLine("uups!"); + } + +} + +#endif + +#if false +class ThreadStop2 +{ + static void Main() + { + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + new Thread(GoX).Start(); + new Thread(GoY).Start(); + Console.WriteLine("finished!"); + } + + private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + Console.WriteLine("Unhandled exception " + e); + throw new NotImplementedException(); + } + + static void GoX() + { + try + { + for (int i = 0; i < 10; i++) + { + Console.Write("X"); + if (i == 2) + { + throw null; // NullReferenceException wird ausgelöst + } + } + } + catch (Exception ex) + { + Console.WriteLine("Exception! " + ex.Message); + } + } + + static void GoY() + { + try + { + for (int i = 0; i < 10; i++) + { + Console.Write("Y"); + } + } + catch (Exception ex) + { + Console.WriteLine("Exception! " + ex.Message); + } + } + +} +#endif + + +#if true +class SimpleBlocking +{ + + static void Main() + { + long sum = 0; + bool fertig = false; + Thread mainThread = Thread.CurrentThread; // main thread + + Thread t = new Thread(delegate () + { + for (int i = 0; i <= 1000; i++) + { + sum += i; + } + Console.WriteLine(mainThread.ThreadState); + fertig = true; + }); + + t.Start(); + // Version 1 == zweitbeste Variante + //while (!fertig) { Thread.Sleep(10) }; + + // Version 2 == schlecht + //Thread.Sleep(10); + + // Version 3 == beste Variante + t.Join(); // warten bis dieser Thread t beendet wurde + Console.WriteLine("Summe = " + sum); + + } + +} + +#endif \ No newline at end of file diff --git a/ADIS_Csharp/ConsoleApp/obj/ConsoleApp.csproj.nuget.dgspec.json b/ADIS_Csharp/ConsoleApp/obj/ConsoleApp.csproj.nuget.dgspec.json new file mode 100644 index 0000000..d9016bd --- /dev/null +++ b/ADIS_Csharp/ConsoleApp/obj/ConsoleApp.csproj.nuget.dgspec.json @@ -0,0 +1,66 @@ +{ + "format": 1, + "restore": { + "C:\\work\\source\\ADIS_Projects\\ADIS_Csharp\\ConsoleApp\\ConsoleApp.csproj": {} + }, + "projects": { + "C:\\work\\source\\ADIS_Projects\\ADIS_Csharp\\ConsoleApp\\ConsoleApp.csproj": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "C:\\work\\source\\ADIS_Projects\\ADIS_Csharp\\ConsoleApp\\ConsoleApp.csproj", + "projectName": "ConsoleApp", + "projectPath": "C:\\work\\source\\ADIS_Projects\\ADIS_Csharp\\ConsoleApp\\ConsoleApp.csproj", + "packagesPath": "C:\\Users\\jonas\\.nuget\\packages\\", + "outputPath": "C:\\work\\source\\ADIS_Projects\\ADIS_Csharp\\ConsoleApp\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [ + "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder" + ], + "configFilePaths": [ + "C:\\Users\\jonas\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], + "originalTargetFrameworks": [ + "net6.0" + ], + "sources": { + "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.100\\RuntimeIdentifierGraph.json" + } + } + } + } +} \ No newline at end of file diff --git a/ADIS_Csharp/ConsoleApp/obj/ConsoleApp.csproj.nuget.g.props b/ADIS_Csharp/ConsoleApp/obj/ConsoleApp.csproj.nuget.g.props new file mode 100644 index 0000000..b343193 --- /dev/null +++ b/ADIS_Csharp/ConsoleApp/obj/ConsoleApp.csproj.nuget.g.props @@ -0,0 +1,16 @@ + + + + True + NuGet + $(MSBuildThisFileDirectory)project.assets.json + $(UserProfile)\.nuget\packages\ + C:\Users\jonas\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder + PackageReference + 6.4.0 + + + + + + \ No newline at end of file diff --git a/ADIS_Csharp/ConsoleApp/obj/ConsoleApp.csproj.nuget.g.targets b/ADIS_Csharp/ConsoleApp/obj/ConsoleApp.csproj.nuget.g.targets new file mode 100644 index 0000000..3dc06ef --- /dev/null +++ b/ADIS_Csharp/ConsoleApp/obj/ConsoleApp.csproj.nuget.g.targets @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/ADIS_Csharp/ConsoleApp/obj/project.assets.json b/ADIS_Csharp/ConsoleApp/obj/project.assets.json new file mode 100644 index 0000000..dbf5e69 --- /dev/null +++ b/ADIS_Csharp/ConsoleApp/obj/project.assets.json @@ -0,0 +1,72 @@ +{ + "version": 3, + "targets": { + "net6.0": {} + }, + "libraries": {}, + "projectFileDependencyGroups": { + "net6.0": [] + }, + "packageFolders": { + "C:\\Users\\jonas\\.nuget\\packages\\": {}, + "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {} + }, + "project": { + "version": "1.0.0", + "restore": { + "projectUniqueName": "C:\\work\\source\\ADIS_Projects\\ADIS_Csharp\\ConsoleApp\\ConsoleApp.csproj", + "projectName": "ConsoleApp", + "projectPath": "C:\\work\\source\\ADIS_Projects\\ADIS_Csharp\\ConsoleApp\\ConsoleApp.csproj", + "packagesPath": "C:\\Users\\jonas\\.nuget\\packages\\", + "outputPath": "C:\\work\\source\\ADIS_Projects\\ADIS_Csharp\\ConsoleApp\\obj\\", + "projectStyle": "PackageReference", + "fallbackFolders": [ + "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder" + ], + "configFilePaths": [ + "C:\\Users\\jonas\\AppData\\Roaming\\NuGet\\NuGet.Config", + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" + ], + "originalTargetFrameworks": [ + "net6.0" + ], + "sources": { + "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, + "https://api.nuget.org/v3/index.json": {} + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "projectReferences": {} + } + }, + "warningProperties": { + "warnAsError": [ + "NU1605" + ] + } + }, + "frameworks": { + "net6.0": { + "targetAlias": "net6.0", + "imports": [ + "net461", + "net462", + "net47", + "net471", + "net472", + "net48", + "net481" + ], + "assetTargetFallback": true, + "warn": true, + "frameworkReferences": { + "Microsoft.NETCore.App": { + "privateAssets": "all" + } + }, + "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.100\\RuntimeIdentifierGraph.json" + } + } + } +} \ No newline at end of file diff --git a/ADIS_Csharp/ConsoleApp/obj/project.nuget.cache b/ADIS_Csharp/ConsoleApp/obj/project.nuget.cache new file mode 100644 index 0000000..98d9e11 --- /dev/null +++ b/ADIS_Csharp/ConsoleApp/obj/project.nuget.cache @@ -0,0 +1,8 @@ +{ + "version": 2, + "dgSpecHash": "B/issz7md4Ugx8aunUlMJ48vNPWeGS6Zl7KOWUyYODuWDr8U6Zy9PnrOq1337PcqtV9KilBMCon/LSGUmB2gCA==", + "success": true, + "projectFilePath": "C:\\work\\source\\ADIS_Projects\\ADIS_Csharp\\ConsoleApp\\ConsoleApp.csproj", + "expectedPackageFiles": [], + "logs": [] +} \ No newline at end of file