Hide wait cursor in c#
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Hide wait cursor in c#

  1. #1
    Join Date
    Feb 2008
    Posts
    5

    Hide wait cursor in c#

    Hi guys,

    I have an application in C# running in WM6. I use CeRunAppAtTime to launch my application every 10 min and I want to hide the wait cursor when loading.

    I had this code in my start function:

    [DllImport("coredll.dll")]

    public static extern IntPtr SetCursor(IntPtr hCursor);



    static void Main(string[] args)

    {

    IntPtr hOldCursor = SetCursor(IntPtr.Zero);

    }


    This make the cursor disappear when my application is running but I still have 2 seconds of cursor appearance when my application is loading.


    It's a background application so I don't want the cursor appear at all.


    Can anybody help?

  2. #2
    Join Date
    Feb 2008
    Posts
    5

    Re: Hide wait cursor in c#

    Up?

  3. #3
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: Hide wait cursor in c#

    It is likely that the windows is responsible for the cursor you are seeing while your application is loading and you may not have control over that cursor while your application is still loading. The code you wrote only kicks in once your application has been loaded and is running. By the why do you keep launching the application every 10 minutes? Can't you keep the instance of the application alive for as long as you need to?

  4. #4
    Join Date
    Feb 2008
    Posts
    5

    Re: Hide wait cursor in c#

    Quote Originally Posted by nelo
    It is likely that the windows is responsible for the cursor you are seeing while your application is loading and you may not have control over that cursor while your application is still loading. The code you wrote only kicks in once your application has been loaded and is running. By the why do you keep launching the application every 10 minutes? Can't you keep the instance of the application alive for as long as you need to?
    Think you for your answer Nelo. Maybe I can make my application run as service. Do you know how to make service application on WM6?

  5. #5
    Join Date
    Feb 2008
    Posts
    5

    Re: Hide wait cursor in c#

    Help...

  6. #6
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: Hide wait cursor in c#

    Have a look in MSDN for Windows Service Applications. I don't have any example ready that I can show you so you have to try it yourself. If you get a problem maybe you can put the code you're using in the post.

  7. #7
    Join Date
    Feb 2008
    Posts
    5

    Re: Hide wait cursor in c#

    I finally keep my application in memory and a make a Thread.Sleep(...).

    Thinks you Nelo for your time.
    Last edited by redcode; February 25th, 2008 at 04:51 PM.

  8. #8
    Join Date
    Feb 2012
    Posts
    1

    Re: Hide wait cursor in c#

    Quote Originally Posted by redcode View Post
    Hi guys,
    I have an application in C# running in WM6. I use CeRunAppAtTime to launch my application every 10 min and I want to hide the wait cursor when loading.

    I had this code in my start function:

    [DllImport("coredll.dll")]
    public static extern IntPtr SetCursor(IntPtr hCursor);

    static void Main(string[] args)
    {
    IntPtr hOldCursor = SetCursor(IntPtr.Zero);
    }

    This make the cursor disappear when my application is running but I still have 2 seconds of cursor appearance when my application is loading.

    It's a background application so I don't want the cursor appear at all.

    Can anybody help?
    i know this thread is kind of old but i'll still answer it since i just figured it out also...
    on main sub or form load... before initilaize if exist...before your first code... add the following:

    Thread.CurrentThread.IsBackground = True;
    Thread.CurrentThread.Priority = ThreadPriority.Highest;
    Application.DoEvents();

    doevents refreshes the thread and make CurrentThread.IsBackground work
    this sets the app in the background process mode and you dont see any annoying wait coursor at startup :P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center