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);
{
...
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());
}
}
_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);
{
...
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());
}
}
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=lnk&kid0709&bid&3057&dat1642 _______________________________________________ Alchemi-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/alchemi-developers
