第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

ibatis在多線(xiàn)程下出現(xiàn)異常,提示W(wǎng)ebSessionStore: Could not obtain reference to HttpContext

ibatis在多線(xiàn)程下出現(xiàn)異常,提示W(wǎng)ebSessionStore: Could not obtain reference to HttpContext

DIEA 2018-12-06 13:23:35
我的項(xiàng)目有個(gè)留言短信發(fā)送模塊,是用多線(xiàn)程方式實(shí)現(xiàn)的,同時(shí)對(duì)每條發(fā)送短信的記錄寫(xiě)入數(shù)據(jù)庫(kù),意思就是在多線(xiàn)程下調(diào)用操作數(shù)據(jù)庫(kù)。 ORM是ibatis.?net 在select或insert操作的時(shí)候出現(xiàn)了這個(gè)異常WebSessionStore: Could not obtain reference to HttpContext。其他操作沒(méi)測(cè)試過(guò),應(yīng)該都是提示同樣的錯(cuò)誤。 發(fā)送方法代碼: ??????? private void SendMessage(object i)??????? {??????????? string Mobile = MobileList[(int)i];??????????? mutex.WaitOne();??????????????? SMSSystem.Send(Mobile, MessageContent);??????????????? CommonHelper.WriteLog(EventFlag.InviterCommentsSMSSend, "留言提醒發(fā)送到了手機(jī)號(hào):" + Mobile, SiteMaster);??????????? mutex.ReleaseMutex();??????? } WriteLog()是CommonHelper類(lèi)的靜態(tài)方法。下面我貼上WriteLog()代碼 ??????? public static void WriteLog(EventFlag Event, string Detail, Dictionary<string, string> sitemaster)??????? {??????????? try??????????? {??????????????? EventLog Model = new EventLog();??????????????? EventLogDao EventDao = new EventLogDao();??????????????? Model.UserId = Convert.ToInt32(sitemaster["UserId"]);??????????????? Model.EventNum = (short)Event;??????????????? Model.Detail = Detail;??????????????? Model.Creator = sitemaster["UserName"];??????????????? Model.AddIP = sitemaster["LoginIP"];??????????????? EventDao.Insert(Model);??????????? }??????????? catch(Exception Ex)??????????? {??????????????? throw new Exception(Ex.Message);??????????? }??????? } 我把ibatis 的insert()方法也貼上吧,這是codesmith生成的,應(yīng)該沒(méi)問(wèn)題,而且如果我不在多線(xiàn)程下調(diào)用的時(shí)候也沒(méi)問(wèn)題 ??public void Insert(EventLog obj) {???if (obj == null) throw new ArgumentNullException("obj");???String stmtId = "EventLog.Insert";???InvestmentMapper.Get().Insert(stmtId, obj);??} 勞煩各位高手了,小弟不勝感激!
查看完整描述

1 回答

?
largeQ

TA貢獻(xiàn)2039條經(jīng)驗(yàn) 獲得超8個(gè)贊

因?yàn)閕batis的ISqlMapSession是存儲(chǔ)在Http.Request.Items上的,在你新開(kāi)的線(xiàn)程里是不能操作IIS的上的線(xiàn)程的,根據(jù)ibatis的文檔上說(shuō)的,可以用:HybridWebThreadSessionStore

The DatatMapper component store his working ISqlMapSession on different session store.

On Web environnement, the session
is stored Http.Request.Items.


On windows environnement on the current thread.


You can configure the session storage by specifing the property ISessionStore on ISqlMapper.

This will allow to
set a custom session store like the HybridWebThreadSessionStore This is used for scenarios where most of the you need per request session, but you also does some work outside a request (in a thread pool thread, for instance).

Set it after the configuration and before use of the ISqlMapper.
?


查看完整回答
反對(duì) 回復(fù) 2019-01-21
  • 1 回答
  • 0 關(guān)注
  • 497 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)