c# - Using InvokeRequired when not a Form -
i have event handler, want handled in original thread object created, doesn't block. forms, it's easy use invokerequired force original thread. how do if class not form?
thanks,
pm
this not going easy. first, have create kind message receiving loop on thread in question. need implement isynchronizeinvoke
in such manner posts message containing delegate execute queue target thread can pick , extract delegate , execute it. producer-consumer pattern useful setting up. important thing take away cannot marshal delegate onto thread. target thread has specially designed work. works in ui threads because application.run
gets message loop going control.invoke
method uses.
Comments
Post a Comment