启动控制台应用程序时不显示等待光标

时间:2012-03-16 11:03:18

标签: c# compact-framework console-application

我开发了一个小型控制台应用程序,它实际上会ping一个URL,记录结果,如果需要,重新启动手机,然后安排自己重新运行。

每次申请启动时,客户都抱怨显示“洗衣机”图标(虽然时间不到一秒)。

我将等待光标隐藏在main方法的第一行,但有没有办法阻止等待光标显示?

    static void Main()
    {
        //Hide cursor 
        IntPtr hOldCursor = SetCursor(IntPtr.Zero);

        //Ensure EventLog table is ready
        PrepareDatabase();

        tapi = new Tapi();
        tapi.TAPI_Open();

        //Ping specified URL and restart phone if required.
        PingRestart();

        tapi.TAPI_Close();

        //Set the application to run again after the ping interval has passed
        SystemTime systemTime = new SystemTime(DateTime.Now.AddMilliseconds(RegistryAccess.PingInterval));
        CeRunAppAtTime(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase, ref systemTime);
    }

1 个答案:

答案 0 :(得分:1)

无法禁用等待光标,因为它在应用程序运行之前出现,因此应用程序无法阻止它。

唯一的方法是用C或汇编代码,因为与.NET可执行文件相比,这些语言的启动速度非常快。但是,在执行之前,AntiVirus程序可能会阻止它一段时间。