private void Work(object state)
        {
            Worker       w = null;
            Construction c = null;

            try
            {
                using (ISession s = OpenSession())
                {
                    ITransaction tx = s.BeginTransaction(); // TODO: Once, it returned "null" and the session was already closed!
                    w = new Worker("Emmanuel", 65);
                    s.Save(w);
                    c = new Construction("Bellagio", "Las Vegas Nevada");
                    s.Save(c);
                    tx.Commit();
                }

                using (ISession s = OpenSession())
                {
                    ITransaction tx = s.BeginTransaction();
                    w      = s.Get <Worker>(w.Id);
                    w.Name = "Gavin";
                    c      = s.Get <Construction>(c.Id);
                    c.Name = "W Hotel";
                    tx.Commit();
                }

                Thread.Sleep(50);

                using (ISession s = OpenSession())
                {
                    ITransaction            tx     = s.BeginTransaction();
                    IFullTextSession        fts    = new Impl.FullTextSessionImpl(s);
                    QueryParser             parser = new QueryParser("id", new StopAnalyzer());
                    Lucene.Net.Search.Query query  = parser.Parse("name:Gavin");

                    bool results = fts.CreateFullTextQuery(query).List().Count > 0;
                    //don't test because in case of async, it query happens before actual saving
                    //if ( !results ) throw new Exception( "No results!" );
                    tx.Commit();
                }
                //System.Diagnostics.Debug.WriteLine("Interation " + worksCount + " completed on thread " + Thread.CurrentThread.ManagedThreadId);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                errorsCount++;
            }
            finally
            {
                worksCount++;

                if (w != null || c != null)
                {
                    using (ISession s = OpenSession())
                    {
                        ITransaction tx = s.BeginTransaction();
                        if (w != null)
                        {
                            w = s.Get <Worker>(w.Id);
                            if (w != null)
                            {
                                s.Delete(w);
                            }
                        }
                        if (c != null)
                        {
                            c = s.Get <Construction>(c.Id);
                            if (c != null)
                            {
                                s.Delete(c);
                            }
                        }
                        tx.Commit();
                    }
                }
            }
        }
        private void Work(object state)
        {
            Worker w = null;
            Construction c = null;
            try
            {
                using (ISession s = OpenSession())
                {
                    ITransaction tx = s.BeginTransaction(); // TODO: Once, it returned "null" and the session was already closed!
                    w = new Worker("Emmanuel", 65);
                    s.Save(w);
                    c = new Construction("Bellagio", "Las Vegas Nevada");
                    s.Save(c);
                    tx.Commit();
                }

                using (ISession s = OpenSession())
                {
                    ITransaction tx = s.BeginTransaction();
                    w = s.Get<Worker>(w.Id);
                    w.Name = "Gavin";
                    c = s.Get<Construction>(c.Id);
                    c.Name = "W Hotel";
                    tx.Commit();
                }

                Thread.Sleep(50);

                using (ISession s = OpenSession())
                {
                    ITransaction tx = s.BeginTransaction();
                    IFullTextSession fts = new Impl.FullTextSessionImpl(s);
                    QueryParser parser = new QueryParser("id", new StopAnalyzer());
                    Lucene.Net.Search.Query query = parser.Parse("name:Gavin");

                    bool results = fts.CreateFullTextQuery(query).List().Count > 0;
                    //don't test because in case of async, it query happens before actual saving
                    //if ( !results ) throw new Exception( "No results!" );
                    tx.Commit();
                }
                //System.Diagnostics.Debug.WriteLine("Interation " + worksCount + " completed on thread " + Thread.CurrentThread.ManagedThreadId);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                errorsCount++;
            }
            finally
            {
                worksCount++;

                if (w != null || c != null)
                    using (ISession s = OpenSession())
                    {
                        ITransaction tx = s.BeginTransaction();
                        if (w != null)
                        {
                            w = s.Get<Worker>(w.Id);
                            if (w != null)
                                s.Delete(w);
                        }
                        if (c != null)
                        {
                            c = s.Get<Construction>(c.Id);
                            if (c != null)
                                s.Delete(c);
                        }
                        tx.Commit();
                    }
            }
        }
        private void ReverseWork(object state)
        {
            Worker       w = null;
            Construction c = null;

            try
            {
                using (ISession s = OpenSession())
                {
                    ITransaction tx = s.BeginTransaction();
                    w = new Worker("Mladen", 70);
                    s.Save(w);
                    c = new Construction("Hover Dam", "Croatia");
                    s.Save(c);
                    tx.Commit();
                }

                using (ISession s = OpenSession())
                {
                    ITransaction tx = s.BeginTransaction();
                    w      = s.Get <Worker>(w.Id);
                    w.Name = "Remi";
                    c      = s.Get <Construction>(c.Id);
                    c.Name = "Palais des festivals";
                    tx.Commit();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                errorsCount++;
            }
            finally
            {
                reverseWorksCount++;

                if (w != null || c != null)
                {
                    using (ISession s = OpenSession())
                    {
                        ITransaction tx = s.BeginTransaction();
                        if (w != null)
                        {
                            w = s.Get <Worker>(w.Id);
                            if (w != null)
                            {
                                s.Delete(w);
                            }
                        }

                        if (c != null)
                        {
                            c = s.Get <Construction>(c.Id);
                            if (c != null)
                            {
                                s.Delete(c);
                            }
                        }

                        tx.Commit();
                    }
                }
            }
        }
        private void ReverseWork(object state)
        {
            Worker w = null;
            Construction c = null;
            try
            {
                using (ISession s = OpenSession())
                {
                    ITransaction tx = s.BeginTransaction();
                    w = new Worker("Mladen", 70);
                    s.Save(w);
                    c = new Construction("Hover Dam", "Croatia");
                    s.Save(c);
                    tx.Commit();
                }

                using (ISession s = OpenSession())
                {
                    ITransaction tx = s.BeginTransaction();
                    w = s.Get<Worker>(w.Id);
                    w.Name = "Remi";
                    c = s.Get<Construction>(c.Id);
                    c.Name = "Palais des festivals";
                    tx.Commit();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                errorsCount++;
            }
            finally
            {
                reverseWorksCount++;

                if (w != null || c != null)
                    using (ISession s = OpenSession())
                    {
                        ITransaction tx = s.BeginTransaction();
                        if (w != null)
                        {
                            w = s.Get<Worker>(w.Id);
                            if (w != null)
                                s.Delete(w);
                        }
                        if (c != null)
                        {
                            c = s.Get<Construction>(c.Id);
                            if (c != null)
                                s.Delete(c);
                        }
                        tx.Commit();
                    }
            }
        }