转载:关于Session_End的触发时机

本文探讨了Session_End事件的触发机制及其局限性,并介绍了一个利用Cache实现类似inproc session_end效果的方法。

http://stackoverflow.com/questions/1042881/why-session-end-event-not-raised-when-stateprovider-is-not-inproc

回答里有几个有用的链接,包括msdn官方的定义和一个自定义的StateProvider下包装Session的Timeout并触发事件的做法(代码里是利用Cache的自动失效),达到和inproc的session_end事件类似的效果。

Session_End event fires only when session reached to idle timeout. It does not fire when some navigates to someother or closed the browser window. We can't relay on Session_End event to check user is logged out / not.

帮我优化代码, //------------------------------------------------------------------------------ //These includes are needed for the following template code //------------------------------------------------------------------------------ #include "HoistingHole.hpp" using namespace NXOpen; using namespace NXOpen::BlockStyler; //------------------------------------------------------------------------------ // Initialize static variables //------------------------------------------------------------------------------ Session *(HoistingHole::theSession) = NULL; UI *(HoistingHole::theUI) = NULL; //------------------------------------------------------------------------------ // Constructor for NX Styler class //------------------------------------------------------------------------------ HoistingHole::HoistingHole() { try { WCHAR temp[256]; GetModuleFileName(_AtlBaseModule.GetModuleInstance(), temp, 256); wstring ws(temp); string strDllPath(ws.begin(), ws.end()); // DLL 运行路径 string dllPath = strDllPath.substr(0, strDllPath.find_last_of("\\") + 1); // Initialize the NX Open C++ API environment HoistingHole::theSession = NXOpen::Session::GetSession(); HoistingHole::theUI = UI::GetUI(); theDlxFileName = "HoistingHole.dlx"; theDialog = HoistingHole::theUI->CreateDialog(dllPath + theDlxFileName); // Registration of callback functions theDialog->AddApplyHandler(make_callback(this, &HoistingHole::apply_cb)); theDialog->AddOkHandler(make_callback(this, &HoistingHole::ok_cb)); theDialog->AddUpdateHandler(make_callback(this, &HoistingHole::update_cb)); theDialog->AddFilterHandler(make_callback(this, &HoistingHole::filter_cb)); theDialog->AddInitializeHandler(make_callback(this, &HoistingHole::initialize_cb)); theDialog->AddDialogShownHandler(make_callback(this, &HoistingHole::dialogShown_cb)); } catch(exception& ex) {
03-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值