
前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
using System.Threading; |
public Thread thread; // スレッドの領域
public String TimeStr; // スレッドで時刻を取得
public void NowTime()
{
while(true)
{
TimeStr = DateTime.Now.ToString();
Thread.Sleep(1000);
}
}
|
public Form1()
{
InitializeComponent();
App = new Card(@"c:\data\test\bijin16.jpg", 60, 60);
thread = new Thread(new ThreadStart(NowTime));
thread.IsBackground = true;
thread.Start();
timer1.Start();
}
|
private void MyHandler(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
if (App.bmp == null) Application.Exit();
App.View(g, SP_NO, 20, 20);
textBox1.Text = TimeStr;
}
|
![]()
[Next Chapter ↓] Thread Animation
[Previous Chapter ↑] Thread Join