How to end sessions?

68 views
Skip to first unread message

NRules

unread,
Apr 17, 2019, 12:16:16 PM4/17/19
to NRules Users
How it is possible to end sessions? I saw in one of the posts where it was said "creating sessions is cheap". What is ment by that? Does session implements IDisposable? 

If I need to validate objects once, which is better approach: 
1) Creating one session and putting object into session, calling session.Fire() and then taking object out (as I don't need that object anymore)? Should there be also some timeout after session.Fire() so that everything gets validated?
2) Creating sessions for each object? Is the session automatically disposed or how to end it?

Sergiy Nikolayev

unread,
Apr 23, 2019, 7:49:29 PM4/23/19
to NRules Users
Session does not implement IDisposable - it does not contain any unmanaged resources. When you are done using the session, just stop referencing it, and garbage collector will collect it.
For validation scenarios, if all you have if a handful of facts to insert into the session, it's better to create a new session every time, insert facts into it, call fire, get results, and throw it all out.
Reply all
Reply to author
Forward
0 new messages