如何关机的Java从C#一个人准确的应用 [英] How to shutdown java application correctly from C# one

查看:104
本文介绍了如何关机的Java从C#一个人准确的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有当我使用 CTRL-C ,Java应用程序关闭之前保存所有数据停产其正确的Java应用程序。现在,我使用 Process.Close(),但应用dont't保存任何数据时,我用这个,我也尝试试图关闭这个Java应用程序从我的C#控制台应用程序 Process.CloseMainWindow(),但使用这个什么也没发生,也 Process.Kill(),但使用这个过程刚刚杀没有任何savining。



我怎样才能提高关闭钩子从C#控制台应用程序?


解决方案

一个关闭钩子不能被其他应用程序得到提升。



关闭挂接运行时:




  • 系统程序正常存在。例如, System.exit()被调用,或者
    最后一个非守护线程退出。

  • 虚拟机被终止。例如CTRL-C。这相当于
    杀-SIGTERM PID或杀死-15 PID在Unix系统上。



关机钩子将不运行时:




  • 虚拟机中止

  • 系统SIGKILL信号发送在Unix虚拟机的过程
    系统。例如杀-SIGKILL PID或杀死-9 PID

  • 系统TerminateProcess呼叫发送到进程在Windows系统上。


I have java application which shutdowns correctly when i use CTRL-C, java application saves all data before shutdown. Now i trying to shutdown this java application from my C# console application using Process.Close(), but application dont't save any data when i use this, i also tried Process.CloseMainWindow() but using this nothing is happening, and also Process.Kill() but using this process just killed, without any savining.

How can i raise shutdown hook on java application from C# console application?

解决方案

A shutdown hook cannot be raised by another app.

The shutdown hook runs when:

  • A program exists normally. For example, System.exit() is called, or the last non-daemon thread exits.
  • the Virtual Machine is terminated. e.g. CTRL-C. This corresponds to kill -SIGTERM pid or kill -15 pid on Unix systems.

The shutdown hook will not run when:

  • the Virtual Machine aborts
  • A SIGKILL signal is sent to the Virtual Machine process on Unix systems. e.g. kill -SIGKILL pid or kill -9 pid
  • A TerminateProcess call is sent to the process on Windows systems.

这篇关于如何关机的Java从C#一个人准确的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆