#
goolz
Hi
I tried to write a task manager by using Thread class and NHibernate , but I got the following exception.
I also remove isWeb="true" from facilities.config.
-----------------------------------------
Sample Code:
-----------------------------------------
private Article _article;
private ArticleModule _articleModule;
private void StartTask()
{
Thread thread = new Thread(new ThreadStart(Execute));
thread.Start();
}
private void Execute()
{
try
{
this._article = this._articleModule.GetArticleById(articleId);
// ...
}
catch
{
}
}
-----------------------------------
Exception error
-----------------------------------
Castle.MicroKernel.Facilities.FacilityException was unhandled
Message="WebSessionStore: Could not obtain reference to HttpContext"
Source="Castle.Facilities.NHibernateIntegration"
StackTrace:
at Castle.Facilities.NHibernateIntegration.Internal.WebSessionStore.ObtainSessionContext()
at Castle.Facilities.NHibernateIntegration.Internal.WebSessionStore.GetDictionary()
at Castle.Facilities.NHibernateIntegration.Internal.AbstractDictStackSessionStore.GetStackFor(String alias)
at Castle.Facilities.NHibernateIntegration.Internal.AbstractSessionStore.FindCompatibleSession(String alias)
at Castle.Facilities.NHibernateIntegration.Internal.DefaultSessionManager.OpenSession(String alias)
at Castle.Facilities.NHibernateIntegration.Internal.DefaultSessionManager.OpenSession()
at SAS.Core.CoreModule.GetUndoneTask()
at SAS.Core.Web.TaskMgmt.execute()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
I tried to write a task manager by using Thread class and NHibernate , but I got the following exception.
I also remove isWeb="true" from facilities.config.
-----------------------------------------
Sample Code:
-----------------------------------------
private Article _article;
private ArticleModule _articleModule;
private void StartTask()
{
Thread thread = new Thread(new ThreadStart(Execute));
thread.Start();
}
private void Execute()
{
try
{
this._article = this._articleModule.GetArticleById(articleId);
// ...
}
catch
{
}
}
-----------------------------------
Exception error
-----------------------------------
Castle.MicroKernel.Facilities.FacilityException was unhandled
Message="WebSessionStore: Could not obtain reference to HttpContext"
Source="Castle.Facilities.NHibernateIntegration"
StackTrace:
at Castle.Facilities.NHibernateIntegration.Internal.WebSessionStore.ObtainSessionContext()
at Castle.Facilities.NHibernateIntegration.Internal.WebSessionStore.GetDictionary()
at Castle.Facilities.NHibernateIntegration.Internal.AbstractDictStackSessionStore.GetStackFor(String alias)
at Castle.Facilities.NHibernateIntegration.Internal.AbstractSessionStore.FindCompatibleSession(String alias)
at Castle.Facilities.NHibernateIntegration.Internal.DefaultSessionManager.OpenSession(String alias)
at Castle.Facilities.NHibernateIntegration.Internal.DefaultSessionManager.OpenSession()
at SAS.Core.CoreModule.GetUndoneTask()
at SAS.Core.Web.TaskMgmt.execute()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: