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

问题描述:

我开发了一个小型控制台应用程序,它实质上是一个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); 
    } 
+0

也许如果您将其更改为线程化任务,那么可以使用'ManualResetEvent'来指示何时使用MRE的'WaitOne'方法完成线程。尽管如此,我还没有测试过,所以我不想添加这个解决方案。 – jp2code 2012-03-17 01:34:45

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

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

+0

你的另一种选择是编写一个更复杂的程序,保持在后台运行(而不是重新安排自己)。然后等待光标只显示第一次 - 当你实际启动应用程序。所以它看起来像这样:** while(true){Thread.Sleep(delayMS);使用(tapi = new Tapi()){tapi.TAPI_Open(); PingRestart(); tapi_TAPI_Close(); }} ** – 2014-11-08 20:17:22