没有预期结果的事件

多壮志 2004-09-22 04:26:38
一下是源程序的代码,
但是不知道为什么,好像没有执行WriteChar中的任务?
...............................................
using System;
using System.Timers;

namespace _01_Time
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
///
static int counter=1;
static string displayString="This String will appear one letter at a time";
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
Timer MyTimer =new Timer(100);
MyTimer.Elapsed+=new ElapsedEventHandler(WriteChar);
MyTimer.Start();
Console.WriteLine();
}

static void WriteChar(object source,ElapsedEventArgs e)
{
Console.WriteLine(displayString[counter++%displayString.Length]);
Console.WriteLine("Nothing Happend now!");
}
}
}
...全文
54 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
hbzx 2004-09-22
  • 打赏
  • 举报
回复
应该是Console.ReadLine();吧

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧