I have a component (Say Component1 )which has two public functions and one

event(Say Func1 and Func2 and event is MyEvent) This component is being used

by a second component(Say Component2)

Here is the flow of events

1) Component2 intantiates Component1
2) Component2 registers for the event MyEvent
3) Component2 calls function Func1
4) In Func1 of Component1 the event MyEvent is raised. Func1 has to do more

work but event is raised in the middle of Func1.
5) Component2 receives event and calls Func2.

In this test case I just want to know is there a way to detect/prevent

Component2 from calling Func2 until the call to Func1 ends. It is kind of

reentry problem of the Component1. Because the Component1 is not thread safe.

The Func2 changes the state of the Component2. In this case after executing

Func2 the code will fall back to Func1 which will see a changed state.

Is there a way to stop it or making Component2 not to be re-entrant.

Thanks in advance

Re: Event question by Dale

Dale
Wed Dec 07 17:12:08 CST 2005

If you want to wait until Func1 ends, why not raise the event at the end of
Func1?


"KDV" <kdv@discussions.microsoft.com> wrote in message
news:34DE35EA-3824-4B6B-872F-967104E76A0D@microsoft.com...
>I have a component (Say Component1 )which has two public functions and one
>
> event(Say Func1 and Func2 and event is MyEvent) This component is being
> used
>
> by a second component(Say Component2)
>
> Here is the flow of events
>
> 1) Component2 intantiates Component1
> 2) Component2 registers for the event MyEvent
> 3) Component2 calls function Func1
> 4) In Func1 of Component1 the event MyEvent is raised. Func1 has to do
> more
>
> work but event is raised in the middle of Func1.
> 5) Component2 receives event and calls Func2.
>
> In this test case I just want to know is there a way to detect/prevent
>
> Component2 from calling Func2 until the call to Func1 ends. It is kind of
>
> reentry problem of the Component1. Because the Component1 is not thread
> safe.
>
> The Func2 changes the state of the Component2. In this case after
> executing
>
> Func2 the code will fall back to Func1 which will see a changed state.
>
> Is there a way to stop it or making Component2 not to be re-entrant.
>
> Thanks in advance



Re: Event question by kdv

kdv
Thu Dec 08 07:52:02 CST 2005

Actually Component1 has registered for remote event from Component 3.
Component1 just delegates that event to Component2. When Component1 is doing
its job in Func1 that event comes from remote component3 which runs on a
separate thread. Even I don't know that the Func1 is being called. I pass
back that event to Component2.


"Dale Lundgren" wrote:

> If you want to wait until Func1 ends, why not raise the event at the end of
> Func1?
>
>
> "KDV" <kdv@discussions.microsoft.com> wrote in message
> news:34DE35EA-3824-4B6B-872F-967104E76A0D@microsoft.com...
> >I have a component (Say Component1 )which has two public functions and one
> >
> > event(Say Func1 and Func2 and event is MyEvent) This component is being
> > used
> >
> > by a second component(Say Component2)
> >
> > Here is the flow of events
> >
> > 1) Component2 intantiates Component1
> > 2) Component2 registers for the event MyEvent
> > 3) Component2 calls function Func1
> > 4) In Func1 of Component1 the event MyEvent is raised. Func1 has to do
> > more
> >
> > work but event is raised in the middle of Func1.
> > 5) Component2 receives event and calls Func2.
> >
> > In this test case I just want to know is there a way to detect/prevent
> >
> > Component2 from calling Func2 until the call to Func1 ends. It is kind of
> >
> > reentry problem of the Component1. Because the Component1 is not thread
> > safe.
> >
> > The Func2 changes the state of the Component2. In this case after
> > executing
> >
> > Func2 the code will fall back to Func1 which will see a changed state.
> >
> > Is there a way to stop it or making Component2 not to be re-entrant.
> >
> > Thanks in advance
>
>
>