473,656 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.

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.

Jul 27 '07 #1
5 2332
if your doing gui i would do somthing Graphical
else
back in the old dos days i did the used the \ / -

based on what ur doing....a process bar is a nice thing
if you can calculate the time...or size for units
otherwise when the calculations are not possible

a disabled text box colord as the window is ..can be used also filling it
and scrolling it with dots....

i used 1 progressbar and filled it one way and reversed it the other way and
forward and back....til lthe process was finished

send 1 thread off to do the work
and main or new 2 thread to work the progress bar...

there's some ideas
MJ
<an***********@ yahoo.comwrote in message
news:11******** **************@ 22g2000hsm.goog legroups.com...
>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.

Jul 27 '07 #2
"MikeJ" <ve***********@ sbcglobal.netwr ote in message
news:ek******** ***********@new ssvr21.news.pro digy.net...
if your doing gui
OP begins, "I have a Windows console application"...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 27 '07 #3
an***********@y ahoo.com 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(ThreadSt art(DoWork));
char[] rgchBusy = new char[] { '-', '\', '|', '/' };
int ichBusy = 0;

thread.Start();

// The thread that does the work will set WorkDoneWaitHan dle,
// an instance of a WaitHandle, when it's done.
while (WorkDoneWaitHa ndle.WaitOne(10 00))
{
Console.WriteLi ne("\r" + rgchBusy[ichBusy]);
ichBusy = (ichBusy + 1) % rgchBusy.Length ;
}
}
Jul 28 '07 #4
On Jul 27, 8:10 pm, Peter Duniho <NpOeStPe...@Nn OwSlPiAnMk.comw rote:
antonyliu2...@y ahoo.com 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 therevolvingsla sh( / ) 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 therevolvingsla shes (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(ThreadSt art(DoWork));
char[] rgchBusy = new char[] { '-', '\', '|', '/' };
int ichBusy = 0;

thread.Start();

// The thread that does the work will set WorkDoneWaitHan dle,
// an instance of a WaitHandle, when it's done.
while (WorkDoneWaitHa ndle.WaitOne(10 00))
{
Console.WriteLi ne("\r" + rgchBusy[ichBusy]);
ichBusy = (ichBusy + 1) % rgchBusy.Length ;
}
}

Thanks. I tried your trick. It works. I was using the backspace
character \b, which did not help. The \r absolutely helped.

How about the growing dots (......)?

Of course, simply growing the dots is easy, but I am not sure how to
remove all those dots and then start growing from scratch on the same
line again. Could anyone of you shed some light on this? Thanks.

Jul 30 '07 #5
an***********@y ahoo.com wrote:
Thanks. I tried your trick. It works. I was using the backspace
character \b, which did not help. The \r absolutely helped.

How about the growing dots (......)?

Of course, simply growing the dots is easy, but I am not sure how to
remove all those dots and then start growing from scratch on the same
line again. Could anyone of you shed some light on this? Thanks.
It would be pretty much the same as the "spinning line", except that
rather than writing the \r character each time, you'd only write it when
you'd written as many periods as make up the line you want (presuambly,
no more than there are characters wide on your console :) ).

Pete
Jul 30 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2525
by: Xaradas | last post by:
Someone could tell me why preg_replace eat a slash when it do replacement? <? $stringToReplace = "blah blah {nome} blah blah"; $replacement = "Two slash: \\\\"; $stringToReplace = preg_replace("/{nome}/Us",$replacement,$stringToReplace,1); echo($stringToReplace); #
23
3706
by: Hostile17 | last post by:
I keep coming across people, online and in real life, who believe that to code single tags like <br> and <img> with trailing slashes, <br /> and <img /> is considered "best practice" and when challenged, they say that "everyone's going to be using XML/XHTML soon" and say that they're "getting ready" by coding this way. Coding this way causes validation errors in HTML 4 Transitional and HTML 4 Strict, so it can't be "best practice". ...
6
3052
by: benz | last post by:
I am trying to fork and exec a child by python. Additionally, I am attempting to have a spinning slash while the child is running. My code is as below: import sys, os, time def spin(delay):
4
6582
by: Prince Kumar | last post by:
I joined a company recently and they have a java program which hangs (does nothing) after a while. This is no way consistent. It could succeed quite a few times and can fail a few other times. There is no consistency when it fails. Could anyone here shed some light on how to debug/resolve the issue. I guess IBM looked at the issue and were not able to pinpoint where the issue is. When the program hangs and when force the DB2...
12
2364
by: Raymond Lewallen | last post by:
How to wait for a process to stop completion is my goal. Obviously, the looping while waiting for the HasExited property is not a solution.. but thats the best I can come up off the top of my head. Natuarally it will not work. I expect it to use up all resources looping, which will not allow the process to complete. The process takes about 60 seconds, because the .bat file it is calling is rebuilding mulitple .NET solutions and projects...
15
1439
by: jcrouse | last post by:
Here is my code: Dim sw As StreamWriter = File.CreateText(Application.StartupPath & "\mameversion.bat") sw.WriteLine(lblMameExePath.Text & " -help >""" & Application.StartupPath & "\mameversion.txt""") sw.Close()
0
1488
by: BasicQ | last post by:
I am running an executable from my aspx page with the click of a button. A date is passed as an argument. I am able to get the standardoutput from the Process(Exe) into the label of my page after the process has completed executing. My problem is I need to get the output in the label simultaneously when the EXE is running, not after it has completed executing. Just like when I run the Exe in the cmd prompt. In my code I am opening two...
10
1951
by: Michele Simionato | last post by:
I have always been curious about how people implement mainloops (or, in Twisted terminology, reactors). So I sit down and I wrote the following simple implementation: import itertools class SimpleReactor(object): DELAY = 0.001 # seconds
3
4084
by: somuchh8 | last post by:
Hi, I'm having a lot of trouble with the Win32::Spawn module in perl. Here is my situation, I have a Win32::Spawn call which looks like this: my $success = undef; my $cmdline = EBDTools::os_path("${nh_home}/web/aview/modules/svcrsp-ng/saSync.pl"); $success = Win32::Spawn($^X, "${^X} $cmdline ${optfile}", $pid); if (! $success) { my $lasterr = Win32::GetLastError(); return_configerror("Failed to create commit / sync process...
0
8297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8498
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7311
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.