C#????????????
???????????? ???????[ 2016/5/24 11:05:20 ] ????????C# .NET
????3????? BackgroundWorker
????????????????????????? BackgroundWorker ?????????????????????????????????????????????????????
????С???
????BackgroundWorker ???????????????????????????????????????????
????????ó???????????BackgroundWorker?????????????VS????????????????????ó???
????BackgroundWorker backgroundWorker1 = new BackgroundWorker();
??????????????????????????BackgroundWorker??RunWorkerAsync()?????????????????BackgroundWorker ???????DoWork ??????????к????????DoWork ????????????????????????е??
?????????????????????????completed ????cancelled????RunWorkerCompleted ?????????????????????????????????????????????????
???????????RunWorkerCompletedEventArgs?????Cancelled ????????ж??????Cancel??????ú???????????
????????demo???£?
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender?? EventArgs e)
{
//TransitionalClass tc = new TransitionalClass("xiaoming"?? 10);
//ThreadPool.QueueUserWorkItem(new WaitCallback(TransitionalClass.TestFunction)?? tc);
}
private void button1_Click(object sender?? EventArgs e)
{
this.TestArea2();
}
private System.ComponentModel.BackgroundWorker BackgroundWorker1
= new System.ComponentModel.BackgroundWorker();
private void TestArea2()
{
InitializeBackgroundWorker();
AreaClass2 AreaObject2 = new AreaClass2();
AreaObject2.Base = 30;
AreaObject2.Height = 40;
// Start the asynchronous operation.
BackgroundWorker1.RunWorkerAsync(AreaObject2);
}
private void InitializeBackgroundWorker()
{
// Attach event handlers to the BackgroundWorker object.
BackgroundWorker1.DoWork +=
new System.ComponentModel.DoWorkEventHandler(BackgroundWorker1_DoWork);
BackgroundWorker1.RunWorkerCompleted +=
new System.ComponentModel.RunWorkerCompletedEventHandler(BackgroundWorker1_RunWorkerCompleted);
}
private void BackgroundWorker1_DoWork(
object sender??
System.ComponentModel.DoWorkEventArgs e)
{
//?????DoWork ??????DoWorkEventArgs ?????Result ???????????????????RunWorkerCompleted ?????RunWorkerCompletedEventArgs ?????Result ??????????
AreaClass2 AreaObject2 = (AreaClass2)e.Argument;
// Return the value through the Result property.
e.Result = AreaObject2.CalcArea();
}
private void BackgroundWorker1_RunWorkerCompleted(
object sender??
System.ComponentModel.RunWorkerCompletedEventArgs e)
{
// Access the result through the Result property.
double Area = (double)e.Result;
MessageBox.Show("The area is: " + Area.ToString());
}
}
}
????demo????????MSDN???????????
?????ο????£??????????
????4????????緵???????????????????д?????????????
????FunctionClass??????????????????£?
????public static void TestFunction2(string name?? int age)
????{
????//??????????
????}
???????????£?
????private void Form1_Load(object sender?? EventArgs e)
????{
????Thread t1 = new Thread(new ThreadStart(delegate
????{
????FunctionClass.TestFunction2("eee"?? 5);
????}));
????t1.Start();
????}
????С???
??????????WCF????????????e????????????????????????????????????????WCF???????????????????????????ī????????
??????????????????????wcf???????????????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
?????????????????(java .net ?????).Net?й???????????Asp.net MVC??ζ???????????????????????Trim????Asp.Net WebForm????????????.Net??????????С????asp.net ???????????.Net??????????????????Linux???Jexus?й?Asp.Net Core??ó???asp.net??????????????ASP.NET???????JSON?????????????????? .NET ?? Java ???? IT ???.Net??Ч???????????????ù???ASP.NET MVC???????????Щ?£?.NET???????????????????????.net???????????????Asp.net Core MVC?????Session
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????