something about thread(c#)

原创 2007年10月15日 22:14:00

        thread is very importment element in our project,when we want to manage two or more things ,we can use thread to manage,one thread manage  one thing,that's we ususlly say Multithreading program.

        now,i just want to say something about how to create a thread and then say something about how to work from a thread which is running to another thread.

        how to create thread.first you should use keyword Thread to declare a variable thread ,and should provide a threadstart function to make thread start.  code:                                                                                                                              

            public void printString()
            {
                Console.WriteLine(s1);
            }
            Thread t = new Thread(printString);
            t.Start();

ok,we have created a thread,and make it start. also we can make thread sleeping and make it suspend and so on.

        how to work from one running thread to another thread.we should use delegate that a special declare in c#.

code:

    delegate void setEndable(bool bs, Form e);

        private void SetEndable(bool bs, Form e)
        {
            if ((this.InvokeRequired) & (!this.IsDisposed))
            {
                setEndable d = new setEndable(SetEndable);
                this.Invoke(d, new object[] { bs, e });
            }
            else
            {
                e.Enabled = true;
            }
        }             

in this code ,we  use delegate void setEndable(bool bs, Form e) to declare a method setEnable,this method have two parament : one is bool variable bs and another is Form variabel e,and  then we make setEnable method have it own body. in it's body,first we should judge this thread wheather has been engrossed,if didn't ,we can immediately do thing just like e.Enabled = true,if has been engrossed,first we should declare a SetEndableobject d , and then use Invokemethod to transfer original method has been declared  as delegate .we shoule notice that parament should keep the same with announce(new object[] { bs, e } like (bool bs, Form e)).actually,that's use a recursive method to provide a safe method.

解决:ruby We're sorry, but something went wrong.We've been notified about this issue and we'll take a look at it shortly.

本人是ruby on rails 的初学者,前几天碰到了如上所示的问题,google了老半天,终于在一篇老外的博客上发现了问题,原来查看log目录下的development.log发现了问题所在“!/...
  • zhong871004
  • zhong871004
  • 2009-07-24 15:57:00
  • 8921

一些资料啊

  • 2007年05月21日 11:11
  • 1.62MB
  • 下载

杭电5984之Pocky

Pocky Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submi...
  • ESESZB
  • ESESZB
  • 2017-03-31 22:06:26
  • 493

【HDU 5984 Pocky】+ 数学

Pocky Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Su...
  • WYK1823376647
  • WYK1823376647
  • 2016-12-04 21:37:14
  • 726

HDU5984 Pocky

Pocky Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Su...
  • xky140610205
  • xky140610205
  • 2016-11-28 22:24:22
  • 629

Something about loopback in linux code

before start to saylinux code 3.16.44内核来说只能建立一个lo(loopback口) drivers/net/loopback.c 中定义了loopback de...
  • bigjordon
  • bigjordon
  • 2017-11-17 17:03:57
  • 65

writeup-collision

题目如下 Daddy told me about cool MD5 hash collision today. I wanna do something like that too!ssh col...
  • charlie_heng
  • charlie_heng
  • 2016-11-21 20:22:55
  • 176

HDU 5984 Pocky (数学)

Pocky Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Su...
  • say_c_box
  • say_c_box
  • 2017-07-24 09:30:49
  • 306

HDU 4965 Fast Matrix Calculation(矩阵快速幂)

题目大意:给你两个数字n和k,然后给你两个矩阵a是n*k的和b是k*n的,矩阵c = a*b,让你求c^(n*n)。 直接求的话c是n*n的矩阵所以是1000*1000,会超时的啊。 可以转化一下:(...
  • xu12110501127
  • xu12110501127
  • 2014-08-27 09:44:13
  • 910

2016 ICPC 青岛站 A【water】、B【模拟】、C【规律】、D【概率】

A - Relic Discovery Recently, paleoanthropologists have found historical remains on an island in t...
  • Irish_Moonshine
  • Irish_Moonshine
  • 2017-12-03 23:04:03
  • 102
收藏助手
不良信息举报
您举报文章:something about thread(c#)
举报原因:
原因补充:

(最多只允许输入30个字)