Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么退出应用程序需要这么长时间?Windows mobile 6.5 C#_Windows_Windows Mobile_Windows Mobile 6.5 - Fatal编程技术网

为什么退出应用程序需要这么长时间?Windows mobile 6.5 C#

为什么退出应用程序需要这么长时间?Windows mobile 6.5 C#,windows,windows-mobile,windows-mobile-6.5,Windows,Windows Mobile,Windows Mobile 6.5,在我的Windows应用程序中,当用户单击电源关闭按钮时,我会执行以下操作: void PowerButton_ButtonClicked(object sender) { DialogResult dl = MessageBox.Show(Globals.SECUEXIT, Globals.CMD_EXIT, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultBut

在我的Windows应用程序中,当用户单击电源关闭按钮时,我会执行以下操作:

        void PowerButton_ButtonClicked(object sender)
    {
        DialogResult dl = MessageBox.Show(Globals.SECUEXIT, Globals.CMD_EXIT, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
        if (dl == DialogResult.Cancel)
        {
            return;  //Power off canceled, nothing to do
        }
        else
        {
            Program.btConn.send(BtMsg.OFF);          //Send the turn off instruction to the BT device.
            Program.scr_SplashScreen.exitRequest();  
            Application.Exit();
        }
    }
在我的手机上关闭应用程序大约需要15秒。我怎样才能加快这个过程


谢谢

我们不知道你的应用程序关闭时实际在做什么。调用
Application.Exit()
之后会发生什么?运行时必须清理东西——因此它必须调用对象上的Dispose并运行代码,完成所有操作,关闭连接和任何打开的硬件接口,停止所有子线程并释放GC内存。您可以很容易地在Dispose方法或终结器中找到需要很长时间才能执行的内容

如果您还不知道是什么原因导致了问题,请开始删除较大的功能块,看看是哪个功能块导致了速度缓慢,然后深入到其中,删除越来越小的功能块,直到找到为止