WPF multithreaded Operations (2)

Source: Internet
Author: User

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Threading;namespacewindowsformsapplication1{ Public Delegate voidRunhandler (Objecta,message mess);  Public Delegate voidRunHandler1 ();  Public Partial classform1:form {Thread th;        Fox Fox;  PublicForm1 () {InitializeComponent (); Fox=NewFox ("Xiao Zhi"); Label1. Text=Fox.            Name; Fox. Runevent+=Fox_runevent1; Fox. RunEvent1+=Fox_runevent1; //button1. Click+=button1_click;        }        Private voidfox_runevent1 () {System.Threading.Thread.Sleep ( +);//One second delay            if(textbox1.invokerequired) {RunHandler1 RH=NewRunHandler1 (Run);            Textbox1.invoke (RH); }            Else{TextBox1.Text="I went, the Lord of the Kinky"; }                    }                Private voidFox_runevent1 (ObjectA, message mess) {TextBox2.Text="Come on! Pikachu"; }                //private void Fox_runevent1 ()//{        //TextBox2.Text = "Pikachu"; //}        //private void Fox_runevent ()//{        //TextBox1.Text = "Up bar"; //}               classFox {Private string_name;  Public stringName {Get{return_name;} Set{_name =value;} }             PublicFox (stringname) {_name=name; }             Public EventRunhandler runevent;  Public EventRunHandler1 RunEvent1;  Public voidbeshooted () {if(runevent!=NULL) {runevent ( This,NewMessage () {message="I went, the Lord of the Kinky"}); }            }             Public voidBeShooted1 () {if(runevent1!=NULL) {RunEvent1 (); }            }        }                        inti =0; Private voidButton1_Click (Objectsender, EventArgs e) {                        if(i==0) {Fox.                Beshooted (); Th=NewThread (NewThreadStart (Run)); Th.                Start (); I=1; }            Else{TextBox1.Text=""; TextBox2.Text=""; I=0; }            //th. Abort ();Button1. Text = button1. Text.equals ("Prepare") ?"swish.. ":"Prepare"; }        Private voidRun () {Fox.        BeShooted1 (); }        Private voidForm1_Load (Objectsender, EventArgs e) {        }    }     Public classMessage:eventargs { Public stringMessage {Get; Set; }    }}

WPF multithreaded Operations (2)

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.