mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-06 16:06:07 +02:00
Initial winforms content migrated (#18)
* Merge winforms framework content to working branch (#14) * Breadcrumb / TOC / Move net5 to net folder (#15) * change path from net5 to net * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Add .net 5 winforms placeholder article (#16) * added some metadata and adjusted net5 placeholder * corrections * corrections * corrections * Test1 * Swapping landing page vs concept * fix links * Fix links * Fix desc
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
public class BackgroundWorkerForm : Form
|
||||
{
|
||||
private BackgroundWorker backgroundWorker1;
|
||||
private Button button1;
|
||||
private TextBox textBox1;
|
||||
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.EnableVisualStyles();
|
||||
Application.Run(new BackgroundWorkerForm());
|
||||
}
|
||||
public BackgroundWorkerForm()
|
||||
{
|
||||
backgroundWorker1 = new BackgroundWorker();
|
||||
backgroundWorker1.DoWork += new DoWorkEventHandler(BackgroundWorker1_DoWork);
|
||||
backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorker1_RunWorkerCompleted);
|
||||
button1 = new Button
|
||||
{
|
||||
Location = new Point(15, 55),
|
||||
Size = new Size(240, 20),
|
||||
Text = "Set text safely with BackgroundWorker"
|
||||
};
|
||||
button1.Click += new EventHandler(Button1_Click);
|
||||
textBox1 = new TextBox
|
||||
{
|
||||
Location = new Point(15, 15),
|
||||
Size = new Size(240, 20)
|
||||
};
|
||||
Controls.Add(button1);
|
||||
Controls.Add(textBox1);
|
||||
}
|
||||
private void Button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
backgroundWorker1.RunWorkerAsync();
|
||||
}
|
||||
|
||||
private void BackgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
// Sleep 2 seconds to emulate getting data.
|
||||
Thread.Sleep(2000);
|
||||
e.Result = "This text was set safely by BackgroundWorker.";
|
||||
}
|
||||
|
||||
private void BackgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
textBox1.Text = e.Result.ToString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user