Example #1
0
    //-- FILE SEARCH

    public void SearchFiles(string s)
    {
        Searching = s.Length > 0;

        if (!Searching)
        {
            // Search done
            Invoke("HideProgress", 0.01f);
            SourceFolder.Initialize();
        }
        else
        {
            // Reset results
            sDirs  = new List <String> ();
            sFiles = new List <String> ();

            // Dispose current thread
            if (thread != null && thread.IsBusy)
            {
                thread.Abort();
                // thread.Dispose ();
            }

            // Initalize thread
            thread = new BackgroundThread();
            thread.WorkerSupportsCancellation = true;
            thread.DoWork += delegate {
                // Destroy elements
                MainThreadDispatcher.Instance().Enqueue(SourceFolder.DestroyAll);

                // Get search results
                GetResults(s);

                // Display search results
                MainThreadDispatcher.Instance().Enqueue(delegate {
                    SourceFolder.Display(sDirs, sFiles, true);
                });

                // Hide progress
                MainThreadDispatcher.Instance().Enqueue(HideProgress);
            };

            // Run thread
            thread.RunWorkerAsync();
        }
    }
Example #2
0
 public Form1()
 {
     InitializeComponent();
     BackgroundThread.RunWorkerAsync();
 }