bubu (bubu) rakstīja koderi kopienā, |
Class c = ...; c.Event += handleris; // ... public void handleris(object sender, EventArgs e) { if (this.textBox1.InvokeRequired) { this.Invoke(new EventHandler(delegate(object s, EventArgs a) { handleris(s, e); })); } else { this.textBox1.Text = "text"; } }
class Class { delegate void InvokeEvent(EventArgs e); public event EventHandler Event; public Class() { ThreadPool.QueueUserWorkItem(new WaitCallback(Work)); } void Work() { OnEvent(new EventArgs()); } protected void OnEvent(EventArgs e) { if (Event != null) Event(this, e); } }
Nopūsties: