Skip to content

Commit

Permalink
编写线程不安全的控制台输出
Browse files Browse the repository at this point in the history
  • Loading branch information
walterlv committed Aug 22, 2024
1 parent 4212e79 commit 58ce875
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion samples/LoggerSample.MainApp/LoggerSample.MainApp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<DCUseGeneratedLogger>preferReference</DCUseGeneratedLogger>
</PropertyGroup>
Expand Down
14 changes: 13 additions & 1 deletion samples/LoggerSample.MainApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using dotnetCampus.Logging.Attributes;
using System;
using System.Threading.Tasks;
using dotnetCampus.Logging.Attributes;
using dotnetCampus.Logging.Configurations;
using dotnetCampus.Logging.Writers;

Expand Down Expand Up @@ -31,6 +33,16 @@ public static void Main(string[] args)
.AddBridge(LoggerBridgeLinker.Default)
.Build()
.IntoGlobalStaticLog();

Run();
}

private static void Run()
{
Parallel.For(0, 0x00010000, i =>
{
Log.Debug($"[TEST] {DateTime.Now:HH:mm:ss}");
});
}
}

Expand Down

0 comments on commit 58ce875

Please sign in to comment.