如何处理意外消失但运行窗口的状态? [英] How to handle unexpectedly disappear but running window's state?

查看:74
本文介绍了如何处理意外消失但运行窗口的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为一些并行运行的应用程序添加了一个终止操作的过程,并且主应用程序删除了一些使用过的文件,以便在主应用程序结束时安全关闭。问题是,有时主应用程序由于某些意外的异常而终止,有时它似乎已经结束但它只是消失并运行在某些可能在后台导致其他应用程序运行的地方,并让处于打开状态的文件保持使用状态。这就是为什么我需要创建一个监视这个正在运行的应用程序存在的服务。



现在这个意外消失的应用程序的Windows状态是什么?另外我如何对仍然打开并被另一个进程使用的文件执行删除操作,从而可能导致拒绝访问。

I have added a procedure for termination action for some parallel running applications and deletion of some used files by main application to be shutdown safely when main application ends up. problem is that sometimes main application terminates due to some unexpected exceptions and sometimes it seems to be ended but it just disappears and run some where may be in background which cause other applications running and let remain used files in open state. That's why I need to create a service which monitor existence of this running application.

Now what will be the windows state of such unexpectedly disappeared application? also how can i perform deletion action on such files which are still open and used by another process and thus may cause access denied.

推荐答案

Hi


我认为你可以使用 Mutex Class 来查找运行应用程序的另一个例子。



看看这个:

单实例C#应用程序 - 适用于.NET 2.0





但是为什么关闭后应用程序不会被终止?如果使用某些计时器或线程,则必须在关闭应用程序之前通过停止它们来处理它,例如在 FormClosed 活动。



看这些也不错:



流程未在计划结束时终止



Application.Exit方法
Hi
I think you can use Mutex Class to find out another instance of running application.

And look at this too:
Single-Instance C# Application - for .NET 2.0


But why wont the application be terminated after shutting down? If some Timers or Threads are used, you must handle it by stopping them before shutting down the app, for example in FormClosed event.

It's not bad to look at these:

Process not terminated at the end of the program

Application.Exit Method


这篇关于如何处理意外消失但运行窗口的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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