using System.Threading;
using System.Runtime.Remoting.Messaging;
public partial class Form1 : Form
{
public delegate void ShowMessage();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ShowMessage myMessage = new ShowMessage(GetInvoked);
myMessage.BeginInvoke(new AsyncCallback(RefreshWindow), null);
Thread myThread = new Thread(GetThreadInvoked);
myThread.Name = "GetInvokedClick";
myThread.IsBackground = true;
myThread.Start();
}
private void GetInvoked()
{
MessageBox.Show("Async Started");
}
private void GetThreadInvoked()
{
MessageBox.Show("Thread Started");
}
private void RefreshWindow(IAsyncResult asResult)
{
AsyncResult result = (AsyncResult)asResult;
ShowMessage msg = (ShowMessage)result.AsyncDelegate;
msg.EndInvoke(asResult);
}
}
Wednesday, October 15, 2008
Subscribe to:
Posts (Atom)