作者GANTZZ (我爱吃虾子)
看板C_Sharp
标题[问题] 请问一个执行序的问题
时间Mon Sep 1 18:14:46 2008
各位板友好
小弟现在在写一个程式
.CS档的程式码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsApplication8
{
public partial class Form1 : Form
{
int a = 0, b = 0,c=0;
bool aa;
public Form1()
{
InitializeComponent();
}
public void count()
{
while (mythread2.IsAlive == true)
{
a++;
label1.Text = a.ToString();
}
}
public void justsleep()
{
Thread.Sleep(5000);
}
ThreadStart mythreadstart1 = new ThreadStart(count);
Thread mythread1 = new Thread(mythreadstart1);
ThreadStart mythreadstart2 = new ThreadStart(justsleep);
Thread mythread2 = new Thread(mythreadstart2);
mythread1.Start();
mythread2.Start();
private void label1_Click(object sender, EventArgs e)
{
}
}
}
在debug的时候 会在 mythread1.Start();和mythread2.Start();这两行出现以下的错误讯息:
类别、结构或介面成员宣告中无效的语汇基元 '('
请问各位板友
小弟是否有哪里搞错了
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.129.27.144
1F:→ kenshinn:因为你的程序不是写在函式中 09/01 19:15