08=== random Name System for cross-thread access.

Source: Internet
Author: User

3, Process:process-> method: 1. Get the operating system process: Process.getprocess () 2. Start the application: Process.Start ("program name", "File to open"); open Web address: Process.Start ("Iexplore.ext", "htttp://www.baidu.com"); 3. When the program is not a global type, the program name is added to the path. 4, example method:. Thread ();. Kill (); 4, Thread:thread-> properties and methods: Static: 1, thread.sleep (int time milliseconds) = = "Thread stops how many milliseconds 2, thread.currentthread;==> gets the current default main thread. (initial thread) instance: 1, Thread.Start (); marks the start of the thread, waiting for the CPU to execute. 2, Thread. isbackground;=== "marks the new thread as a background thread. 3, Thread. Priority=thread.normal;==> recommends the operating system level for this thread. is not necessarily effective. 4, Thread. The ID of the managerthreadid;==> thread. 5, Thread. Abort ();==> the last resort, so that the thread ends directly. 6, Thread. Join (after int milliseconds);==> waits for thread thread execution to complete ==> This method is executed by the main thread. The thread executing the code waits for the thread to execute after a certain amount of time has been executed. When the time is set too long, the main thread command waits until the current thread ends. When written in a loop, it can be cycled and the start time is the last execution time. -line Cheng The foreground thread, the process exits when all foreground threads exit. The background thread is not blocked. ->main method. The program will default to create a foreground main thread to execute the Main method: 5, cross-thread access issues: 1, close the restriction of cross-thread access: CONTROL.CHECKFORLLEGACROSSTHREADCALLS=FALSE;2, determine whether cross-thread access: Determine the current control. The value of invokerequired, if true, indicates that the control is not created by the current access thread. To call the thread that originally created him for access. Use the control name. Invoke (pass in a delegate to invoke the method you want to access.) ), when false. Execute the access. if (the name of the control. invokerequired) {control name. Invoke (The new action< parameter type passed in > () =>{executed by the party(}else{), the parameter to pass in);//Find the thread that created the control, and execute the delegate method to access the control directly. }

  

1 namespace_04 cross-thread access resolution2 {3      Public Partial classFrmmain:form4     {5          Publicfrmmain ()6         {7 InitializeComponent ();8         }9 Ten         BOOLIsruning =false; One         Private voidButton1_Click (Objectsender, EventArgs e) A         { -Isruning =!isruning; -Button1. Text ="Start | pause". Split (New Char[] {'|'},stringsplitoptions.removeemptyentries) [Convert.ToInt32 (isruning)]; the             string[] name ="Baoshin Baozhong Balambaszo side let side Hong Junxi bian Shi are (Cao's wife) step Stallion (Acorn) step to clarify Bing original (Zhao first) junks Chen Yu Chen Yu Chen Lin (Kong) Chen Gong (Public station) Chenxiang (Zhonglin) Mr. Chen Chen Deng (yunlong) Chen Wei Chen Wu (Zorie) Chen Lanchen gui Chen Ji Chen Zhen (filial) Chen Yu Chen Sun Chen (Liu Biao ex-wife) Chen on the Chen Ying agronomy (Chang Wen) Chen style Chen Yi Chen Tai Gawks (Wei Xiangxi) Chen Tai Gawks (Guohuai the legatus) Chen Yu Chen Junchen Cheng Cheng Cheng Cheng Yufan (trebizond) Cheng (German armature) Cheng Wei Cheng ji stylization Zeng (Kimitaka) Zenbitzen CEN faint into a He Chengyu into the Yi into Ji Cao Cao (Mendea deceive) Cao Song Cao Tengcaoren (Loving) Cao Hong (Zilian) Cao De Cao Leopard Cao Tsao (bu second wife) Cao Cao Pi (son Huan) Cao Zhi (Zi Jian) Tsao (Imperial chaise) Caochincaoshuchao Cao Shu (child) Cao Kungcao Jin (Larry) always beware (Wenzhong) Cao Shu Cao Yuchao (Lanqing) Cao Shuang (Zhaober) Cao Xi Cao Xun Cao Yanchao tert-Cao according to Cao Quiff (Shiyan) Cao Lin Cao Shu (Jing Ming) Cai Yong (bo Jiejie) Cai Mao Cai (Liu Biao wife) Cai and Cai Xun Cai Cai Linton Yu Jiangxun Chun Yu dan Tri Yi Tri Li Yong Tri Yu (season GUI) Chi Zhou ping Triyuti forgive Triff (Liu Yan wife) Chang Chang qi Chanyu Chei Eagle Cuan XI Beecher Gidondro (Zhongying) Dong Zhong Dowager (Liu Yan wife) Dong Ji Dong Juan dong mother (Dong Zhou) Dong Cheng Dong Zhao (Masahito) Dong Ji (Yuan Dynasty) Dong Guifei ( Dong Cheng) Dong (young Slaughter) Dong Ji Dong Heng Dong Chao Dong Ji Dong Yun Dong Juedong tea that Dong Ji Dong Ji Dong Zhaoding original (Jianyang) Ding (Seung-so) Dingfeiding (Caocao Wives) Dingyi (courtesy) Ding (salute) ding-xian Ding Lidin mi (Yan Jing) Dingfongdeng Wedding Dengmodern Dengzhi (Beumio) Deng Copper Deng Antonacci Deng Ai (a) Dengzhong Dung Dengxian (Yizhou will) Dengxian (Meng Da) Elsie away Du Jidu attack Dujondu Rudo micro du Yi duhkhi Duruidu Pre-section GUI section simmer the Dailing Shingwu Governor Mail Mink Chan Party all think King bring hole main Big Joe E-Huan Russia ho Burning Gofu Fu (Bang) Fu Gan (Yan Cai) Fushen Fu fu gu ' Fu queen (Han Yu di ) Fu de". Split (New Char[] {' '}, stringsplitoptions.removeemptyentries); -  -Random r =NewRandom (); -             //int i = 0; +             //While (true) -             //{ +             //i++; A             //int ran= r.next (0, N); at             //Thread.Sleep (+); -             //txt. Text = Name[ran]; -             //if (i = = ten) -             //    { -             //Break ; -             //    } in  -             //} to             //Create a thread to perform a loop +Thread thread =NewThread (() = -             { the                  while(isruning) *                 { $ Panax Notoginseng                     intran = R.next (0, $); -Thread.Sleep ( -); the                     //determines whether the current control is a control created by the current thread +                     if(txt. invokerequired) A                     { theTxt. Invoke (NewAction (() = +                         { -  $Txt. Text =Name[ran]; $  -                         })); -                     } the                     Else -                     {Wuyi Console.WriteLine (Name[ran]); the                     } -                     //txt. Text = Name[ran]; Wu  -                 } About             }); $             //set thread as background thread -Thread. IsBackground =true; -             //tagged thread is ready to complete - thread. Start (); A  +         } the  -  $  the     } the}

08=== random Name System for cross-thread access.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.