CannibalSmith (cannibalsmith) rakstīja koderi kopienā, @ 2009-03-13 15:41:00 |
|
|||
public class Class { delegate void InvokeEvent(EventArgs e); public event EventHandler Event; public Class() { ThreadPool.QueueUserWorkItem(new WaitCallback(Work)); } void Work() { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new InvokeEvent(OnEvent), new EventArgs()); } protected void OnEvent(EventArgs e) { if (Event != null) Event(this, e); } }vai
public class Class { public event EventHandler Event; public Class() { ThreadPool.QueueUserWorkItem(new WaitCallback(Work)); } void Work(object state) { OnEvent(new EventArgs()); } protected void OnEvent(EventArgs e) { if (Event != null) { if (Thread.CurrentThread == Application.Current.Dispatcher.Thread) { Event(this, e); } else { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new EventHandler(Event), this, e) } } } }?
Nopūsties: