// Private interface
 private void Service_Waiting_On_Input()
 {
     CPackageInputState input = CPackageManager.Get_Package_Input( InputID );
     if ( input.State == EInputPackageState.Finished )
     {
         State = EOutputPackageState.CopyAndHash;
         m_BackgroundTask = new CCopyAndHashWorker( CPackageManager.UnpackDirectory + @"/" + Config.Source, Config.Destination );
         m_BackgroundTask.RunWorkerAsync();
         Console.WriteLine( "Building output: " + Config.Tag );
     }
 }
        private void Service_Copy_And_Hash()
        {
            switch ( m_BackgroundTask.Get_Completion_Status() )
            {
                case EWorkStatus.CompletionFailure:
                case EWorkStatus.Invalid:
                    throw new Exception( "Attempt to copy and hash package failed" );

                case EWorkStatus.CompletionSuccess:
                    Console.WriteLine( "Successfully built output: " + Config.Tag );
                    Update_Output_Hashes( ( m_BackgroundTask as CCopyAndHashWorker ).CumulativeHash );

                    State = EOutputPackageState.Finished;
                    m_BackgroundTask = null;
                    break;
            }
        }
        // Private interface
        private void Service_Pending_Download()
        {
            if ( m_BackgroundTask == null && CPackageManager.Get_Input_Packages_In_State_Count( EInputPackageState.Downloading ) < CConfigSettings.Instance.MaxConcurrentDownloads )
            {
                State = EInputPackageState.Downloading;
                m_BackgroundTask = new CDownloadWorker( Config );
                m_BackgroundTask.RunWorkerAsync();

                Console.WriteLine( "Downloading package: " + Config.Name );
            }
        }
        private void Service_Hashing_Download()
        {
            switch ( m_BackgroundTask.Get_Completion_Status() )
            {
                case EWorkStatus.CompletionFailure:
                case EWorkStatus.Invalid:
                    throw new Exception( "Attempt to hash downloaded file failed" );

                case EWorkStatus.CompletionSuccess:
                    Console.WriteLine( "Successfully hashed downloaded file: " + DownloadedFile );
                    CHash download_hash = ( m_BackgroundTask as CHashWorker ).Hash;
                    if ( !Config.Verify_Download_Hash( download_hash ) )
                    {
                        throw new Exception( "Download hash check failure on package: " + Config.Name );
                    }
                    State = EInputPackageState.Decompressing;
                    m_BackgroundTask = new CDecompressWorker( DownloadedFile, CPackageManager.UnpackDirectory );
                    m_BackgroundTask.RunWorkerAsync();
                    Console.WriteLine( "Decompressing package: " + Config.Name );
                    break;
            }
        }
        private void Service_Downloading()
        {
            switch ( m_BackgroundTask.Get_Completion_Status() )
            {
                case EWorkStatus.CompletionFailure:
                case EWorkStatus.Invalid:
                    throw new Exception( "Attempt to download package failed" );

                case EWorkStatus.CompletionSuccess:
                    Console.WriteLine( "Successfully downloaded package: " + Config.Name );
                    DownloadedFile = ( m_BackgroundTask as CDownloadWorker ).DownloadedFileName;
                    State = EInputPackageState.HashingDownload;
                    m_BackgroundTask = new CHashWorker( DownloadedFile, 8 );
                    m_BackgroundTask.RunWorkerAsync();
                    Console.WriteLine( "Hashing package: " + Config.Name );
                    break;
            }
        }
        private void Service_Decompressing()
        {
            switch ( m_BackgroundTask.Get_Completion_Status() )
            {
                case EWorkStatus.CompletionFailure:
                case EWorkStatus.Invalid:
                    throw new Exception( "Attempt to decompress file failed" );

                case EWorkStatus.CompletionSuccess:
                    Console.WriteLine( "Successfully decompressed downloaded file: " + DownloadedFile );
                    State = EInputPackageState.Finished;
                    m_BackgroundTask = null;
                    break;
            }
        }