First of all, do not mess with the priority of the thread if something that you do will make it slower.
Secondly, as Phill said, you need to cache your SessionFactory, or you will rebuild the configuration every time you need a session object.
You can do something like this or move the code in if to the static constructor of the class:
private static SessionFactory _factory = null; public static ISession ObterSessao() { if(_factory == null) { string ConnectionString = ConfigurationHelper.LeConfiguracaoWeb("EstoqueDBNet");
joshperry
source share