Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.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
C# Don';t在控制台应用程序启动时显示等待光标_C#_Compact Framework_Console Application - Fatal编程技术网

C# Don';t在控制台应用程序启动时显示等待光标

C# Don';t在控制台应用程序启动时显示等待光标,c#,compact-framework,console-application,C#,Compact Framework,Console Application,我开发了一个小的控制台应用程序,它本质上是ping一个url,记录结果,如果需要重新启动手机,然后安排自己再次运行 客户抱怨每次应用程序启动时都会显示“洗衣机”图标(虽然不到一秒钟) 我将等待光标隐藏在主方法的第一行中,但是是否有任何方法可以阻止等待光标显示 static void Main() { //Hide cursor IntPtr hOldCursor = SetCursor(IntPtr.Zero); //Ensur

我开发了一个小的控制台应用程序,它本质上是ping一个url,记录结果,如果需要重新启动手机,然后安排自己再次运行

客户抱怨每次应用程序启动时都会显示“洗衣机”图标(虽然不到一秒钟)

我将等待光标隐藏在主方法的第一行中,但是是否有任何方法可以阻止等待光标显示

    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);
    }

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


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

如果您将其更改为线程任务,则可以使用
ManualResetEvent
来告知何时使用MRE的
WaitOne
方法完成线程。我还没有测试过这个,所以我不想把它作为一个解决方案。你的另一个选择是编写一个在后台运行的更复杂的程序(而不是安排自己重新启动)。然后,等待光标仅显示第一次-当您实际启动应用程序时。所以它看起来是这样的:while(true){Thread.Sleep(delayMS);使用(tapi=new tapi()){tapi.tapi_Open();PingRestart();tapi_tapi_Close();}