Beispiel #1
0
        // == Monitor Lock States ==

        private void DisplayLockStatus()
        {
            try
            {
                ICatalogReadWriteLock RWLock = Globals.catalog.GetReadWriteLock(_monitorCatalogPath);
                monitorLabel.Text = "NonBlockingWriteLocked: " + RWLock.IsCurrentlyNonBlockingWriteLocked.ToString()
                                    + ", WriteLocked: " + RWLock.IsCurrentlyWriteLocked.ToString();
            }
            catch
            {
            }
        }
Beispiel #2
0
        private void GetCatalogReadWriteLockBtn_Click(object sender, EventArgs e)
        {
            int iCat = catListBox.SelectedIndex;

            if (iCat >= 0)
            {
                ICatalogReadWriteLock RWLock = Globals.catalog.GetReadWriteLock(_flatCalaogList[iCat].LocationPath);
                MessageBox.Show("Catalog: " + _flatCalaogList[iCat].LocationPath + "\n\n"
                                + "ICatalogReadWriteLock.IsCurrentlyNonBlockingWriteLocked = " + RWLock.IsCurrentlyNonBlockingWriteLocked.ToString() + "\n"
                                + "ICatalogReadWriteLock.IsCurrentlyWriteLocked = " + RWLock.IsCurrentlyWriteLocked.ToString() + "\n"
                                + RWLock.GetType().ToString() + "\n\n"
                                + "Note: Call to GetReadWriteLock() returns ICatalogReadWriteLock that can be used to lock\\unlock a catalog for reads & write etc.",
                                "Catalog.GetReadWriteLock()");
            }
        }
Beispiel #3
0
        private void LoadButton_Click(object sender, EventArgs e)
        {
            treeView1.Nodes.Clear();
            nodeCatalogTypeXml = null;
            EnableDisable();

            String path = GetCatalogContentStoreLocation();

            if (path == "")
            {
                MessageBox.Show("Catalog path is invalid or does not contain a \"ContentStore\" folder.");
                return;
            }

            // First check for locks (ie. Catalog is in flux being rebuilt)

            ICatalogReadWriteLock RWLock = Globals.catalog.GetReadWriteLock(path);

            if (RWLock.IsCurrentlyNonBlockingWriteLocked || RWLock.IsCurrentlyWriteLocked)
            {
                MessageBox.Show("Catalog is busy. Try again soon.\nCatalog is currently write locked.");
                return;
            }

            // Load Catalog XML -- Locking as we go so others don't try a modify it while we read

            RWLock.StartNonBlockingWriteOperation(10000);   //10 second time out (usually reads all XML under 1 second on my laptop VM)
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                _catalogXml             = new CatalogParser(path);
                _catalogPackageMetaData = _catalogXml.GetPackageMetaData();
                BuildToc();
                EnableDisable();

                if (_catalogXml.InstalledBooks == null)
                {
                    MessageBox.Show("No data found! Note that only VS 11 catalog folders contain HV2 XML data.");
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;
                RWLock.ExitNonBlockingWriteOperation();
            }
        }