Hi Michael,

 

The case you specify should only apply to multi use applications. Once a single use application started there should be no more threads added to it so there is no need to fire the ThreadFinished event after all initial threads finished and the application finished. I think that if there are no more threads added then the problem you describe should not come up.

 

Looking at multi use applications…

 

The _Running flag must stay true for multi use applications once the application was started and until the application is explicitly stopped.

 

The main reason for this is that a multi use app would just add threads on the fly and start them with StartThread . Now if you look at the code in StartThread you will notice that it calls StartGetFinishedThreads() which in turn will see that _Running is false and start another GetFinishedThreads thread.

 

So it looks like we should restrict the StartThread call only for multi use applications.  Unless there are objections to this change I would add this to the bug list in SourceForge so we can keep track of the change.

 

I may have misunderstood the problem you described. If so then please send over some more details or client side code that reproduces the problem.

 

Regards,

Tibor

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael James Meadows
Sent: Thursday, May 04, 2006 2:07 PM
To: [email protected]
Subject: [Alchemi-developers] ApplicationFinish and ThreadFinish events

 

Noticed the following curious behaviour with ApplicationFinish and ThreadFinish events.

 

If an alchemi client has 0 ApplicationFinish event handlers then ThreadFinish events are not fired after the application has finished.

If an alchemi client has 1 ApplicationFinish event handlers then ThreadFinish events are fired after the application has finished.

 

This happens because _Running is not set to false when the application finishes and there isn't an ApplicationFinish event handler. (StartGetFinishedThreads requires that _Running = false before starting another GetFinishedThread thread responsible for firing thread finish events.)

 

The following segment of code shows where the problem may be:

 

GApplication.GetFinishedThreads

...

       if (ApplicationFinish != null && !this._MultiUse)
       {
        ...
        Manager.Owner_StopApplication(Credentials, _Id);

 

        logger.Debug("Raising AppFinish event (for single-use app)..."+_Id);
        _Running = false;
        try
        {
         ApplicationFinish.BeginInvoke(null, null);
        }
        catch (Exception ex)
        {
         logger.Debug("ApplicationFinish Event-handler error: "+ex.ToString());
        }
       }

       break;

...

 

This does suggest that _Running = false; could be put in an else statement to cover when there is no ApplicationFinish event handler.

 

...

       if (ApplicationFinish != null && !this._MultiUse)
       {
        ...
        Manager.Owner_StopApplication(Credentials, _Id);

 

        logger.Debug("Raising AppFinish event (for single-use app)..."+_Id);

        _Running = false;
        try
        {
         ApplicationFinish.BeginInvoke(null, null);
        }
        catch (Exception ex)
        {
         logger.Debug("ApplicationFinish Event-handler error: "+ex.ToString());
        }
       }

       else

       {

        _Running = false;

       }

       break;

...

 

This would mean that ThreadFinish events are still fired after the application has finished regardless of whether or not an ApplicationFinish event handler has been added. However, I've been reluctant to change this simply because I don't understand how threads should be treated after the application has finished. This may be related to multi-use application that were discussed earlier this year.

 

Any ideas/thoughts would be appreciated.

 

Thanks,

 

Michael.


------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=k&kid0709&bid&3057&dat1642 _______________________________________________ Alchemi-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/alchemi-developers

Reply via email to