Re: I wanna implement the revolving slash while the process is executing

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



antonyliu2002@xxxxxxxxx wrote:
I have a Windows console application, which takes around 3 minutes to
complete the execution.

I am interested in implementing something animate while users are
waiting for the process to complete.

If you have experience with Linux/Unix, you should be very familiar
with the revolving slash ( / ) or the growing dots ( ...... ), which
you normally see, when a process is taking some time.

I guess I may have to implement 2 threads. One does the real dirty
work behind, the other displays the revolving slashes (maybe it is a
combination of --, / and \) or grows the dots.

Any idea how to implement this fun stuff? Thanks.


How fancy do you want?

Here's a simple example:

static void Main()
{
Thread thread = new Thread(ThreadStart(DoWork));
char[] rgchBusy = new char[] { '-', '\', '|', '/' };
int ichBusy = 0;

thread.Start();

// The thread that does the work will set WorkDoneWaitHandle,
// an instance of a WaitHandle, when it's done.
while (WorkDoneWaitHandle.WaitOne(1000))
{
Console.WriteLine("\r" + rgchBusy[ichBusy]);
ichBusy = (ichBusy + 1) % rgchBusy.Length;
}
}
.



Relevant Pages

  • I wanna implement the revolving slash while the process is executing
    ... I have a Windows console application, which takes around 3 minutes to ... complete the execution. ... I am interested in implementing something animate while users are ... waiting for the process to complete. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Need output from visual basic script
    ... I was already using that switch. ... switch causes cmd.exe to terminate after execution. ... but didn't address the problem of the Clipper program waiting ... swpruncmd op code to call cmd.exe to execute the script. ...
    (comp.lang.clipper)
  • Re: problems in pausing and resumig threads
    ... Now in Cmaingui if somebody presses pause, then i execute the following code ... thread doesn't stop execution and hence procedure doesnt stop execution. ... no use, because SuspendThread should not even exist, and given that it does ... instead of waiting on the thread handle to become signaled. ...
    (microsoft.public.vc.mfc)
  • =?windows-1252?B?S25vd2xlZGdlIHNoYXJpbmeFLi46KQ==?=
    ... experience and other achievements in ... the field of Linux/Unix by visiting: ... We sit around waiting for the right ... If you really want something get in the game and start making ...
    (alt.os.linux.suse)
  • Java threads & deamons
    ... We are trying to make a "batch" execution in a Oracle DB 9.2.4 with ... procedure/package without waiting the result from the ... The java class we have created has this piece of code inside: ... waiting the thread forkato ending: ...
    (comp.lang.java.databases)