Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Without taking into account needing to update a GUI (which would require doing a control.Invoke()), here is a very easy way to run something in the background using the ThreadPool. The great thing about the thread pool is that you don't have to worry about creating, disposing and keeping track of threads.</p> <pre><code>static void Main(string[] args) { lacie BackupDrive = new lacie(); BackupDrive.findLacie(); xml xmlFile = new xml(); xmlFile.ProcessXML(); size BackupSize = new size(); System.Threading.ThreadPool.QueueUserWorkItem(s =&gt; { BackupSize.GetSize(xmlFile.Path); }); int SizeofBackup = (int)(((BackupSize.BackupSize) / 1024f) / 1024f) / 1024; Console.WriteLine("Drive Letter: " + BackupDrive.Drive); Console.WriteLine("Volume Name: " + BackupDrive.VolumeLabel); Console.WriteLine("Free Space: " + Convert.ToString(BackupDrive.AvailableSize) + "G"); Console.WriteLine("Size of Lacie: " + Convert.ToString(BackupDrive.TotalSize) + "G"); Console.WriteLine("Backup Size: " + Convert.ToString(SizeofBackup + "G")); Console.WriteLine("Backing up " + BackupSize.FileCount + " files found in " + BackupSize.FolderCount + " folders."); Console.ReadKey(true); } </code></pre> <p>You could add something else to the thread pool that just kept writing to the console like this:</p> <pre><code>System.Threading.ThreadPool.QueueUserWorkItem(s =&gt; { while (true) // might want a real condition like while(!backupNotDone) { int SizeofBackup = (int) (((BackupSize.BackupSize)/1024f)/1024f)/1024; Console.WriteLine("Backup Size: " + Convert.ToString(SizeofBackup + "G")); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload