views:

60

answers:

1

Disposing a control from by calling its own BeginInvoke() is a good idea or bad idea? Or shall I use the parent control or something like that to accomplish this task?

I'm using Invoke because I'm accessing the control form another thread.

+2  A: 

I cannot see why it should be a bad idea. Invoke or BeginInvoke does not do any special tricks other than calling the method on the right thread.

Fredrik Mörk
So it doesn't matter which control I use to call Invoke it will just switch to that context and run it. Is that right?
dr. evil
In general I think it is a good idea to call `Invoke` on the control on which you want to invoke the delegate passed to the `Invoke` statement, but for practical reasons *I don't think* it matters, as long as the control that you call `Invoke` on is owned by the same thread as the target control.
Fredrik Mörk
Great answer thanks, although you said "I think", I'll take it as you are sure :)
dr. evil
@dr. evil: you take is as you want, *I think* only means that it's your insurance kicking in if something goes wrong, not mine ;o)
Fredrik Mörk