|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace CrossThread
{
public partial class Form1 : Form
{
private Thread guidThread;
private string newGUID;
public delegate void GuidThreadCallBack();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
guidThread = new Thread(new ThreadStart(CreateNewGuid));
guidThread.Start();
}
public void CreateNewGuid()
{
while (true)
{
newGUID = Guid.NewGuid().ToString();
//textBox1.Text = Guid.NewGuid().ToString();
try
{
this.Invoke(new GuidThreadCallBack(setTextBoxValue));
}
catch { guidThread.Abort(); }
}
}
private void setTextBoxValue()
{
textBox1.Text = newGUID;
textBox1.Refresh();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.