I may be greatly misunderstanding this threading scenario, but that's why I'm asking.
What would/might happen in the following situation (assume C# threading)? Note: this scenario is simplified to the core issue, extra functionality is ignored.
I have 2 objects, a and b, which are instances of classes A and B respectively; 'b' is a member of 'a'.
'b' is running a processing loop and has a few other activities continually doing something. At one point, 'b' detects a situation which causes it to send an event to 'a'. When 'a' recieves this event, it executes the following code:
void b_eventFoo()
{
b.UnhookEvents();//clears the delegate that truggered this event function
this.b = new B();
b.HookEvents(this);//connects the new b object to this A
}
What happens to the old 'B' object? The original 'b' still is doing some processing and the very thread that triggered the event could still be executing. I don't understand threading well enough to predict the results of this scenario.
Does it even matter?
Please let me know if I should clarify anything.