1

I have tried using this code sample:

private void DoShortRunningTask()
{
    using (new StWaitCursor())
    {
        Thread.Sleep(5000); // 5 sec delay. 
        .. do some work .. 
    } 
}

From: http://www.codeproject.com/KB/cpp/WaitCursor.aspx

But it did not do anything for me, since I did not have a main form. I do not need a main form. My C# project type is Windows Application, but the only GUI it shows if any is error or success messages dialogs. Is there a way for me to fake the existence of a WinForm (so that it exists but is not visible)? Would the mouse cursor have to be over it in order to show up?

Hamish Grubijan
  • 10,562
  • 23
  • 99
  • 147
  • 1
    So you don't want user feedback as a form that shows processing status, you just want user feedback as a cursor attached to nothing that shows processing status. You should review Windows UI Guidelines, imho. – Bahri Gungor Sep 28 '11 at 16:54
  • 1
    It doesn't make sense. If there's no UI then the user isn't waiting for anything. If she actually is, some externally visible side-effect like a printout for example, then *do* show ui. ProgressBar, typically. Also prevents error message boxes from disappearing behind another window. – Hans Passant Sep 28 '11 at 17:33

3 Answers3

1

I don't think it would be good practice just to change the cursor when it's not in your UI. You wouldn't want another program messing with the cursor in your UI. If you just want to show that your application is running, have you thought of using a tray app. These are relatively simple to create.

Here's an example I just googled: http://alanbondo.wordpress.com/2008/06/22/creating-a-system-tray-app-with-c/

You can also show speech bubble messages as your run progresses etc, if you want to let the user know things are happening.

F5 F5 F5
  • 159
  • 2
  • 7
0

I do not need a main form

Yes, you do. Any UI interaction needs a form, sorry.

way for me to fake the existence of a WinForm (so that it exists but is not visible)?

How is that faking?

Make a form, make it invisible (transaprent - check all the properties on the form class and you will find it) and finished ;) Standard approach. Also tell it not to show up in the forms collection in the bottom of the screen and minimize it and you are finished. nothing fake here.

TomTom
  • 61,059
  • 10
  • 88
  • 148
0

TomTom++

Are you just wanting to change the current cursor?

Try this

http://www.csharp-examples.net/hourglass-wait-cursor/

Matt
  • 3,638
  • 2
  • 26
  • 33