gpt4 book ai didi

c# - Apache Ignite.NET 和 AppDomain.CurrentDomain.ProcessExit

转载 作者:行者123 更新时间:2023-11-30 15:53:35 27 4
gpt4 key购买 nike

考虑类,利用 Apache Ignite.NET 库

public interface ICluster
{
void Join();

void Leave();
}

public class ApacheIgniteClusterImpl : ICluster
{
private IIgnite Ignite { get; set; }

private int MulticastPort { get; }

private int ThinClientPort { get; }

public ApacheIgniteClusterImpl(int multicastPort = 47401, int thinClientPort = 10800)
{
MulticastPort = multicastPort;
ThinClientPort = thinClientPort;
}

public void Join()
{
if (Ignite != null)
{
return;
}

var configuration = new IgniteConfiguration
{
ClientConnectorConfiguration = new ClientConnectorConfiguration
{
Port = ThinClientPort,
},
DiscoverySpi = new TcpDiscoverySpi
{
IpFinder = new TcpDiscoveryMulticastIpFinder()
{
MulticastPort = MulticastPort,
}
},
JvmOptions = new List<string>()
{
"-DIGNITE_NO_SHUTDOWN_HOOK=true",
},
};

// Start
Ignite = Ignition.Start(configuration);
}

public void Leave()
{
Ignition.Stop(null, true);
Ignite = null;
}
}

通常,在 .NET Standard 中,我们可以 Hook AppDomain.CurrentDomain.ProcessExit我们可以做清理工作的事件。但是,一旦 JVM 由 Apache Ignite.NET 创建 AppDomain.CurrentDomain.ProcessExit当我用 kill <pid> 杀死 MacOS 上的控制台应用程序时永远不会被触发.

我在调试时做了一些研究,发现它会在 private static Jvm CreateJvm(IgniteConfiguration cfg, ILogger log) 之后的某个地方发生。已被调用。

知道那里发生了什么,如果有机会我们可以连接到 AppDomain.CurrentDomain.ProcessExit

UPD:都不是AppDomain.CurrentDomain.DomainUnload也不System.Runtime.Loader.AssemblyLoadContext.Unloading也会起作用。

最佳答案

ProcessExit is not guaranteed to be called .

我相信 Ignite.NET 与此无关。我已经检查过这个(没有引用或启动 Ignite),如果你强行终止进程,则不会调用处理程序。

关于c# - Apache Ignite.NET 和 AppDomain.CurrentDomain.ProcessExit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52148621/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com