Thread R = new Thread(new ThreadStart(InUsrGame));
R.Start();但InUsrGame没执行,是怎么回事

解决方案 »

  1.   

    static void InUsrGame()
    {
       //do somthing
    }
      

  2.   


    namespace xxx
    {
        public class tclass
        {
             static tclass()
             {
                 Thread R = new Thread(new ThreadStart(InUsrGame));
                 R.Start();
             }
        }
    }
      

  3.   

    static void InUsrGame()
    {
      MessageBox.Show("看看会不会报错");
    }
      

  4.   

    这个我有做了,,,
    我是记录日志log来查看,是否程序有进入但是没打印出来.
      

  5.   

    可以执行呀using System;
    using System.Threading;
    public class tclass
    {
        public tclass()
        {
            Thread R = new Thread(new ThreadStart(InUsrGame));
            R.Start();
        }
        static void InUsrGame()
        {
            Console.WriteLine("ok");
        }
    }
    class A
    {
        static void Main()
        {
          tclass t=new tclass();
          Console.ReadLine();
        }
    }
      

  6.   

    你确定已经调用static tclass()了?静态构造函数?
      

  7.   

    我这里只是一个类库,
    不是控制台程序....只要有引用到tclass的一个方法
    static tclass()
    {
        //刚开始都会执行...
    }但 线程Thread所委托的方法,就是进不入...
      

  8.   

    把static tclass()修改成tclass
    把static void InUsrGame()修改为void InUsrGame()再测试
      

  9.   


    这个
    static tclass()
    {
        //程序有走到这里来
    }
    我有个方法是记录日志的: command.addLog("xxxx");会有打印出日志出来
      

  10.   

    InUsrGame 是静态的啊
    static void InUsrGame()
      

  11.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using System.Threading;namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {
               
            }        private void button1_Click(object sender, EventArgs e)
            {
                tclass c = new tclass();
            }
        }    public class tclass
        {
            static tclass()
            {
                Thread R = new Thread(new ThreadStart(InUsrGame));
                R.Start();
            }        public static void InUsrGame()
            {
                MessageBox.Show("只有第一次点击才会弹出提示框");        }
        }
    }
      

  12.   

    我试试,非常感谢各位的帮忙
    我之前都是像我上面那样在写代码的..都运行得好好的...
    不知道这次为什么会这样..我还对比之前写的可以运行的代码,static class这部分是一模一样的..真郁闷了.
      

  13.   

    问题找出来了,是 Windows消息队列 拒绝访问出的问题...