续:JScript.NET学习历程(例程) 利用JScript.NET和.NET类库创建线程。

blues-star 2004-08-13 06:41:43
http://blog.csdn.net/runmin/archive/2004/08/13/74038.aspx


/*
* Compile sample:
* jsc /t:exe /out:Threading.exe Threading.js
*/

//
// Using directives
//

import System;
import System.Threading;
import System.Windows.Forms;


// the thread
var theThread : WriteConsoleThread = new WriteConsoleThread();

// standard thread
Application.Run(new Form());

// stop the thread
theThread.StopThread = true;





// thread runner class
class WriteConsoleThread
{
// thread start
private var threadStart : ThreadStart;

// thread
public var SingleThread : Thread;

// stop flag
public var StopThread : boolean;

// Constructor
public function WriteConsoleThread()
{
this.StopThread = false;
this.threadStart = printDot;
this.SingleThread = new Thread(this.threadStart);
this.SingleThread.Start();
}

// print '.' to console screen
private function printDot()
{
while (!this.StopThread)
{
Console.Write(".");
Thread.Sleep(1000);
}

Console.WriteLine("");
Console.Write("Stopping thread...");
this.SingleThread.Abort();
}
}
...全文
113 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
blues-star 2004-08-16
  • 打赏
  • 举报
回复
UP
blues-star 2004-08-13
  • 打赏
  • 举报
回复
下一个例程,预告:

利用JScript.NET和图形处理类库,取得汉字点阵,并输出到控制台。



前两个学习要点总结:

第一个:http://community.csdn.net/Expert/topic/3268/3268833.xml?temp=.7015039

1、类的创建;
2、窗体和Winform控件的使用;
3、事件处理;
4、变量声明(注意与JScript的区别);
5、function保留字的使用(同样注意与Jscript的区别)。

第二个:即本贴

1、jsc.exe(编译工具)的使用,熟悉参数;
2、创建线程;
3、线程的基本操作;
4、在Jscript.NET中使用delegate(代理)。

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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