This is an automated email from the ASF dual-hosted git repository. aaronai pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
commit fdbe255f8c0f0f9fbe85e84d89a060e206a3d448 Author: Aaron Ai <[email protected]> AuthorDate: Fri Mar 17 13:47:00 2023 +0800 Enable ServerGarbageCollection for example --- csharp/README-CN.md | 2 +- csharp/examples/examples.csproj | 1 + csharp/rocketmq-client-csharp/Utilities.cs | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/csharp/README-CN.md b/csharp/README-CN.md index dadaf2e9..7f3a343e 100644 --- a/csharp/README-CN.md +++ b/csharp/README-CN.md @@ -49,7 +49,7 @@ dotnet test -l "console;verbosity=detailed" ## 日志系统 -我们使用 [NLog](https://nlog-project.org/) 作为日志实现,与 Java 客户端类似,我们允许使用环境来自定义日志相关的配置。 +我们使用 [NLog](https://nlog-project.org/) 作为日志实现,与 Java 客户端类似,我们允许使用环境变量来自定义日志相关的配置。 * `rocketmq_log_level`:日志输出级别,默认为 INFO。 * `rocketmq_log_root` diff --git a/csharp/examples/examples.csproj b/csharp/examples/examples.csproj index 37f6a477..c4836826 100644 --- a/csharp/examples/examples.csproj +++ b/csharp/examples/examples.csproj @@ -6,5 +6,6 @@ <PropertyGroup> <OutputType>Exe</OutputType> <TargetFrameworks>net5.0;netcoreapp3.1</TargetFrameworks> + <ServerGarbageCollection>true</ServerGarbageCollection> </PropertyGroup> </Project> diff --git a/csharp/rocketmq-client-csharp/Utilities.cs b/csharp/rocketmq-client-csharp/Utilities.cs index 5505a277..ca334b9b 100644 --- a/csharp/rocketmq-client-csharp/Utilities.cs +++ b/csharp/rocketmq-client-csharp/Utilities.cs @@ -30,6 +30,8 @@ namespace Org.Apache.Rocketmq public static class Utilities { private static long _instanceSequence = 0; + private static readonly int ProcessId = Process.GetCurrentProcess().Id; + private static readonly string HostName = System.Net.Dns.GetHostName(); public const int MasterBrokerId = 0; public static int GetPositiveMod(int k, int n) @@ -47,12 +49,12 @@ namespace Org.Apache.Rocketmq public static int GetProcessId() { - return Process.GetCurrentProcess().Id; + return ProcessId; } public static string GetHostName() { - return System.Net.Dns.GetHostName(); + return HostName; } public static string GetClientId()
