4

Let's say we have the main class and another class with some custom events called OnFoo.

Now, the second class has a seperate thread that should call these events, which the main thread should be able to hook into. But as soon as those events are raised, the main class tries to do something on itself that isn't possible, since the event raised function is actually still in that second thread.

How do I raise OnFoo so the main class can change properties of itself when the event is raised?

PS: I have read about Invoke and BeginInvoke, but haven't had any success with them.

Codecat
  • 2,213
  • 3
  • 28
  • 39
  • Well it would help if you'd show the code which tries to use Invoke/BeginInvoke, as that's probably the right approach. You also need to tell us what kind of app this is - WPF, WinForms, something else... – Jon Skeet Jan 17 '11 at 08:05
  • It's WinForms. The main class is a form, the second class is a class that calls the event which the form hooks into. – Codecat Jan 17 '11 at 08:07

0 Answers0