473,800 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

myTimer.Stop() can't stop!

Hi there.

I am displaying a string which will appear 1 char at a
time. The problem is after it display the 1st string, it
will keep on continue.

When i uncomment the myTimer.stop(), it does not even run
at all.. cannot see anything on the command prompt.

Any help?

using System;
using System.Timers;

namespace Handling_Events ___1_char_at_a_ time
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static int counter = 0;
static string displayString = "Hello World!";

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
Timer myTimer = new Timer(100);

myTimer.Elapsed += new ElapsedEventHan dler(WriteChar) ;
myTimer.Start() ;

//myTimer.Stop();

Console.ReadLin e();
}

static void WriteChar(objec t source, ElapsedEventArg s e)
{
Console.Write(d isplayString[counter++ %
displayString.L ength]);

}
}
}

Any help?

I am starting to learn events as well.

Regards,
Chua Wen Ching
Nov 15 '05 #1
1 2337
Hi,

Try using the System.Threadin g.Timer.

Regards,

- Bruce.
"Chua Wen Ching" <cw*@cwc.com> wrote in message
news:02******** *************** *****@phx.gbl.. .
Hi there.

I am displaying a string which will appear 1 char at a
time. The problem is after it display the 1st string, it
will keep on continue.

When i uncomment the myTimer.stop(), it does not even run
at all.. cannot see anything on the command prompt.

Any help?

using System;
using System.Timers;

namespace Handling_Events ___1_char_at_a_ time
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static int counter = 0;
static string displayString = "Hello World!";

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
Timer myTimer = new Timer(100);

myTimer.Elapsed += new ElapsedEventHan dler(WriteChar) ;
myTimer.Start() ;

//myTimer.Stop();

Console.ReadLin e();
}

static void WriteChar(objec t source, ElapsedEventArg s e)
{
Console.Write(d isplayString[counter++ %
displayString.L ength]);

}
}
}

Any help?

I am starting to learn events as well.

Regards,
Chua Wen Ching

Nov 15 '05 #2

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

Similar topics

2
5207
by: engsol | last post by:
I'm using Python to parse a bunch of s/w test files and make csv files for later report generation by MS ACCESS....(my boss loves the quick turn-around compared to C). Each log file may contain one or more 'sessions', and each session may contain one or more 'nodes'. Each session in the log has an ASCII start and stop time, as does each node. I have the basic parse part done for parameters, errors, etc., but noticed my routine for...
8
2046
by: Eric Osman | last post by:
My javascript program has reason to want to stop. For example, function A has 5 lines, the second of which calls function B, which has 5 lines, the first of which calls function C. But function C discovers that something is very wrong so it does an "alert" saying something like Sorry, couldn't make the necessary connection
2
2372
by: Mike Bennett | last post by:
Does the .NET framework (using VB.NET) support the ability to programmatically STOP a device prior to its removal from the system? I have need to move data from a computer on one network to a computer on a different network. For various reasons, I am not allowed to join these networks. Additionally, neither computer is allowed to disconnect from its network to connect to the other network I have decided to use a USB jump drive to move the...
5
27346
by: Paul O. Morris | last post by:
Is there a script that I can run to stop a particular SQL server service on Win2003 server? I'm looking for a similar script to restart that service as well. Thanks.
2
2124
by: Adrian MacNair | last post by:
Hi I need some help if anyone can understand my crap javascript. The problem is that after the slideshow ends (reaches the end of array) it should stop, but the timeout doesn't clear and I can see the layer flashing. I wrote a slideshow script. When you click a hypertext link it calls the function speed() and passes the variable 5000: var myvar = 0; // Starting variable at zero var myTimeout;
2
2863
by: Prasad | last post by:
Hi, I am writing a service which takes a long time to stop after the OnStop call is given by the Services Snap-in. The problem is I cannot cut down on the time that it takes to Stop. The Service snap-in gives me the error saying that the service did not respond to the Stop call in a timely fashion. So is there any method by which I can get around this problem. Thanks Prasad
8
3524
by: Matt Theule | last post by:
While stepping through an ASP.NET project, I found that data was being inserted into my database even though I was not stepping through the code that inserted the data. I have a single page with inline code. The page has a Datagrid, a textbox and a button. When the button is clicked, the value of the textbox is inserted into the table whose contents are displayed on the page. The problem occurs when I set a breakpoint on a line *IN*...
7
7236
by: shai | last post by:
I am working at .net 1.1, writing in c#. I have windows service with a COM object. Every unexpected time The COM object throw an error that make my service get stuck (do not respond). I can catch this error. I want to restart my windows service every time the COM object throws an error. I use System.ServiceProcess.ServiceController to stop and start my service. But there is one thing I do not understand:
0
2202
by: mattcfisher | last post by:
Hi, I have two windows services running together. One is the main program, and one is an "updater" wrapper for the main. The updater service starts and stops the main one (as in you should never start or stop main service manually, only updater). On most computers it works great, the updater's onStop() can start and stop the main service perfectly. On some computers, though, the updater hangs when it tries to stop the main service. It...
0
10507
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...
0
10279
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10255
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
10036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7582
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
5473
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
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.