简体   繁体   中英

Don't display wait cursor when console app is launching

I've developed a small console application that essentially pings a url, records the result, restarts the phone if required and then schedules itself to run again.

The client is complaining about the "washing machine" icon being displayed (albeit for less than a second) every time the application launches.

I'm hiding the wait cursor in the first line of my main method but is there any way of preventing the wait cursor from displaying at all?

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

There is no way to disable the wait cursor, as it appears before the application runs so the application can't block it.

The only way is to code it in C or Assembly, as those languages start up very fast in comparison to .NET executables. But still, an AntiVirus program could block it for a while before it executes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM