标签: shutdown

如何以编程方式将笔记本电脑带入睡眠模式

我可以使用哪些API或工具来查询系统的功能,并选择最合适的用于将PC置于睡眠,休眠或关机模式?

谢谢你的任何指示.

.net api shutdown hibernate-mode sleep-mode

4
推荐指数
1
解决办法
4618
查看次数

当应用程序有未保存的数据时,处理注销/关闭/重启的正确方法是什么?

在WPF App.Current.SessionEnding必须在几秒钟内返回,否则出现"应用程序没有响应"窗口.因此,在此事件处理程序中不能要求用户保存他的数据,因为用户的响应需要的时间超过几秒钟.

我认为解决方案是取消注销/关闭/重启,并在用户回答文件保存对话框时恢复它.

    ReasonSessionEnding _reasonSessionEnding;

    App.Current.SessionEnding +=
        new SessionEndingCancelEventHandler(Current_SessionEnding);

    void Current_SessionEnding(object sender, SessionEndingCancelEventArgs e)
    {
        if (_dataModified)
        {
            e.Cancel = true;
            _reasonSessionEnding = e.ReasonSessionEnding;
            Dispatcher.CurrentDispatcher.BeginInvoke(new Action(EndSession));
        }
    }

    void EndSession()
    {
        if (SaveWithConfirmation()) // if the user didn't press Cancel
            //if (_reasonSessionEnding = ReasonSessionEnding.Logoff)
                // logoff
            //else
                // shutdown or restart ?
    }
Run Code Online (Sandbox Code Playgroud)

问题是ReasonSessionEnding没有告诉我Windows是关闭还是重新启动(它没有区分两者).

那么,我的程序应该如何处理会话结束事件?它甚至应该做什么,或者在这个事件上什么都不做是标准的?

要求用户将其更改保存在我的主窗体的OnClosing方法中,这样他就不会丢失数据,但我认为"应用程序没有响应"窗口并不表示正常的工作流程.

我想,取消关机是不可取的,因为其他一些程序已经关闭了.

c# wpf shutdown

4
推荐指数
1
解决办法
2297
查看次数

Windows关机对话框

有没有办法使用任何语言(首选:C/C++,VB,Haskell,批次)打开Windows XP关闭对话框(带有三个按钮的按钮 - 按下Shift时挂起,关机,重启和休眠)?

我想我可以在我的C++程序中加载msgina.dll,但我不知道下一步该做什么 - 在dll中用什么函数来显示对话框?

windows winapi shutdown

4
推荐指数
1
解决办法
953
查看次数

如何以编程方式使系统退出待机状态?

有没有办法在c#或vb.net中执行此操作?我必须使系统退出待机状态,并在特定时间间隔处于待机模式时播放通知声音.这可能吗?

.net c# vb.net shutdown

4
推荐指数
2
解决办法
793
查看次数

我可以主动关闭我的iOS应用吗?

有一些罕见的数据损坏情况,而不是在同一个会话中尝试恢复,我想执行一些修复,然后关闭应用程序,以便下次启动是安全的.

没有硬件崩溃的应用程序与愚蠢的东西*(unsigned int *)0 = 0xDEADBEEF,我无法在Cocoa中找到导致正常关闭的API.

更新:找到关于这个主题的文档,这基本上证实了怀疑,并指出exit作为最后的选择:

http://developer.apple.com/iphone/library/qa/qa2008/qa1561.html

iphone shutdown ios

4
推荐指数
1
解决办法
2787
查看次数

关闭Mac目标C.

我需要能够实现以下方法:

  • 关掉
  • 重新开始
  • 注销
  • 睡觉

在Mac上,我正在使用XCode,但似乎无法找出执行这些操作的代码.

有人可以帮我从这里出去吗?

谢谢

macos xcode cocoa shutdown

4
推荐指数
1
解决办法
4515
查看次数

执行某些系统事件,Mac OS X.

我想要

  • 关掉
  • 重新开始
  • 注销
  • 睡觉

我的系统通过我正在制作的应用程序,我似乎无法找到任何原生的Objective C方式来做它并且它真的很难.

任何人都可以指导我做最好的方法:

我试过了:

NSString *scriptAction = @"restart"; // @"restart"/@"shut down"/@"sleep"/@"log out"
NSString *scriptSource = [NSString stringWithFormat:@"tell application \"Finder\" to %@", scriptAction];
NSAppleScript *appleScript = [[[NSAppleScript alloc] initWithSource:scriptSource] autorelease];
NSDictionary *errDict = nil;
if (![appleScript executeAndReturnError:&errDict]) {
    //
}
Run Code Online (Sandbox Code Playgroud)

这根本没有运气,也尝试过:

NSAppleScript* theScript = [[NSAppleScript alloc] initWithSource:
                            @"Tell application \"Finder\" to restart"];
if (theScript != NULL)
{
    NSDictionary* errDict = NULL;
    // execution of the following line ends with EXC
    if (YES == [theScript compileAndReturnError: &errDict]) …
Run Code Online (Sandbox Code Playgroud)

macos shutdown objective-c logout

4
推荐指数
1
解决办法
2996
查看次数

tomcat中的shutdown hook(必要)没有运行

我有一个长期运行的cpu和数据库密集型线程(以低优先级运行),可由管理员请求由我的tomcat应用程序触发.

我为此线程使用了一个关闭钩子,因此如果应用程序被强制停止,它可以在退出之前清理数据库状态.在独立模式下完美运行,使用control-C并在eclipse控制台中取消.

但是当在tomcat下运行时,当我执行时:

$ CATALINA_HOME/bin中/ shutdown.sh

我通过调试日志验证我的servlet contextDestroyed消息是由tomcat发送的,但是对于这个线程,消息无法阻止它,重要的是我的shutdown hook永远不会触发.

我注意到其他人说使用contextDestroyed消息,但这对我不起作用,而且一些问题和答案暗示关闭钩子在tomcat中为它们工作.

我正在使用tomcat 6.0.35.

java tomcat shutdown

4
推荐指数
1
解决办法
2195
查看次数

Intent.ACTION_REBOOT和Intent.ACTION_SHUTDOWN之间的区别

我试图接收(BroadcastReceiver关闭)关闭,启动和重新启动的操作.

我搜索了很多,但我无法弄清楚Intent.ACTION_REBOOT和之间的区别是什么Intent.ACTION_SHUTDOWN,以及什么时候被Intent.ACTION_REBOOT调用(或者我应该说"广播").

可以请有人为我解释一下吗?

android reboot shutdown intentfilter android-broadcast

4
推荐指数
1
解决办法
8310
查看次数

为什么弹簧开机总是在两个小时内停机

我使用它来构建它mvn clean package并获取一个xxx.jar文件.跑$java -jar xxx.jar >> output.log &开始吧,效果很好.

但大约两个小时后,它关机,为什么?这是一个答案,但不适合我>> /sf/answers/1568675881/

这是我的output.log:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.1.9.RELEASE) …
Run Code Online (Sandbox Code Playgroud)

java spring shutdown application-shutdown spring-boot

4
推荐指数
1
解决办法
3072
查看次数