1 using System;
2 using System.Threading;
3 using Telerik.WinControls;
4 using System.Runtime.Remoting.Messaging;
5
6 namespace TestForm
7 {
8 public partial class AsyncForm : Telerik.WinControls.UI.RadForm
9 {
10 public AsyncForm()
11 {
12 InitializeComponent();
13 this.Load += AsyncForm_Load;
14 }
15
16 void AsyncForm_Load(object sender, EventArgs e)
17 {
18 Action<string> ac = SetLabelText;
19 ac.BeginInvoke("hahaha", new AsyncCallback(CallBack), "AsyncState:Yes");
20 }
21
22 private void CallBack(IAsyncResult ar)
23 {
24 string str = ar.AsyncState.ToString();//AsyncState:Yes
25 Action<string> ac = (Action<string>)((AsyncResult)ar).AsyncDelegate;
26 ac.EndInvoke(ar);
27 }
28
29 private void SetLabelText(string text)
30 {
31 Thread.Sleep(2000);
32 this.Invoke(new Action(() => {
33 radLabel1.Text = text;
34 }));
35 }
36 }
37 }