Пример #1
0
 private void Window_Closed(object sender, EventArgs e)
 {
     if (status != Status.Complete && status != Status.Error)
     {
         Common.AbortThread(thread);
     }
 }
Пример #2
0
 public void Cancel()
 {
     if (thread != null)
     {
         Common.AbortThread(thread);
     }
 }
Пример #3
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (!closingWindowExternal)
     {
         Common.AbortThread(Thread);
         DialogResult = false;
     }
 }
Пример #4
0
        public void SetCurrentPath(String path, String demoNameToSelect)
        {
            // really should refresh the demo list

            /*if (path == currentPath)
             * {
             *  SelectDemo(demoNameToSelect);
             *  return;
             * }*/

            this.demoNameToSelect = demoNameToSelect;

            // clear control
            demoCollection.Clear();

            // abort all running threads from thread pool
            foreach (Thread t in threadPool)
            {
                Common.AbortThread(t);
            }

            // check that directory exists, that path isn't blank
            if (path == "" || !Directory.Exists(path))
            {
                return;
            }

            currentPath = path;

            // search folder for *.dem files
            DirectoryInfo directoryInfo = new DirectoryInfo(path);

            threadPoolFull  = false;
            threadPoolCount = 0;
            FileInfo[] files = null;

            try
            {
                files = directoryInfo.GetFiles("*.dem", SearchOption.TopDirectoryOnly);
            }
            catch (UnauthorizedAccessException)
            {
                return;
            }

            foreach (FileInfo fi in files)
            {
                Thread thread;

                try
                {
                    Demo demo = DemoFactory.CreateDemo(fi.FullName);
                    thread = demo.Read((IMainWindow)((Grid)Parent).Parent, (IDemoListView)this);
                }
                catch (Exception ex)
                {
                    /*
                     * Only show an error message here if the user explicitly opened this demo.
                     * The only errors that should be happening are if the demo isn't a valid HL/Source engine demo or if there's some problem opening the file.
                     *
                     * Any errors that occur in the demo reading thread are always shown (the thread handles this).
                     */
                    if (String.Equals(System.IO.Path.GetFileNameWithoutExtension(fi.Name), demoNameToSelect))
                    {
                        Common.Message((Window)((Grid)Parent).Parent, "Error loading demo file \"" + fi.FullName + "\"", ex, MessageWindow.Flags.Error);
                    }

                    // don't add it to the thread pool
                    continue;
                }

                threadPool.Add(thread);
                threadPoolCount++;
            }

            threadPoolFull = true;
        }
Пример #5
0
 public void AbortProcessMonitor()
 {
     Common.AbortThread(processMonitorThread);
 }
Пример #6
0
 private void uiCancelButton_Click(object sender, RoutedEventArgs e)
 {
     Common.AbortThread(thread);
     Close();
 }