Esempio n. 1
0
        internal void CloseAll()
        {
            Debug.WriteLineIf(CLI.FnTrace.Enabled, "StatementList.CloseAll ()");
#if !WIN32_FINALIZERS
            lock (list)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    Item            item    = (Item)list[i];
                    VirtuosoCommand command = item.weakCommand == null ? null : (VirtuosoCommand)item.weakCommand.Target;
                    if (command != null)
                    {
                        command.OnConnectionClose();
                        item.weakCommand = null;
                    }
                    else
                    {
                        CLI.SQLFreeHandle((short)CLI.HandleType.SQL_HANDLE_STMT, item.hstmt);
                    }
                }
                list.Clear();
            }
#else
            if (commands != null)
            {
                lock (commands)
                {
                    for (int i = 0; i < commands.Count; i++)
                    {
                        WeakReference   weak   = (WeakReference)commands[i];
                        VirtuosoCommand target = (VirtuosoCommand)weak.Target;
                        if (target != null)
                        {
                            target.OnConnectionClose();
                            weak.Target = null;
                        }
                    }
                }
                commands.Clear();
            }

            FinalizeAll();
#endif
        }
Esempio n. 2
0
        public override void Close()
        {
            if (futures != null)
            {
                futures.Clear();
                futures = null;
            }

            if (commands != null)
            {
                for (int i = 0; i < commands.Count; i++)
                {
                    WeakReference   weak   = (WeakReference)commands[i];
                    VirtuosoCommand target = (VirtuosoCommand)weak.Target;
                    if (target != null)
                    {
                        target.OnConnectionClose();
                        weak.Target = null;
                    }
                }
            }
        }