public bool Initialize()
        {
            var COM_obj   = new GoogleUpdate3WebMachineClass();
            var class_obj = (IGoogleUpdate3Web)COM_obj;

            appBundle = (IAppBundleWeb)class_obj.createAppBundleWeb();
            appBundle.initialize();
            try
            {
                if (!string.IsNullOrEmpty(GUID))
                {
                    appBundle.createInstalledApp("{" + GUID + "}");     // Particulary application
                    var appweb = (IAppWeb)appBundle[0];
                }
                else
                {
                    appBundle.createAllInstalledApps();     // All installed application
                }
            }
            catch
            {
                DeInitialize();
                return(false);
            }

            return(true);
        }
        static private uint AppTotalBytesDownloaded(IAppBundleWeb appBundle)
        {
            uint bytesCount = 0;

            for (int appIndex = 0; appIndex < appBundle.length; ++appIndex)
            {
                var currState = (ICurrentState)appBundle[appIndex].currentState;
                bytesCount += currState.bytesDownloaded;
            }
            return(bytesCount);
        }
 public void DeInitialize()
 {
     if (appBundle != null)
     {
         while (Marshal.ReleaseComObject(appBundle) > 0)
         {
             ;
         }
         appBundle = null;
     }
     GC.Collect();
 }
        static private int AppInCurrentStateCount(IAppBundleWeb appBundle, currentState state, bool logStates = false)
        {
            int count = 0;

            for (int appIndex = 0; appIndex < appBundle.length; ++appIndex)
            {
                var currState = (ICurrentState)appBundle[appIndex].currentState;

                if (logStates)
                {
                    ToLog(new[] { ((currentState)currState.stateValue).ToString() });
                }

                if (currState.stateValue == (int)state)
                {
                    ++count;
                }
            }
            return(count);
        }
        static void WaitingThread(object infoState)
        {
            IAppBundleWeb appBundle = (IAppBundleWeb)infoState;

            while (true)
            {
                for (int appIndex = 0; appIndex < appBundle.length; ++appIndex)
                {
                    if (AppInCurrentStateCount(appBundle, currentState.STATE_CHECKING_FOR_UPDATE) == 0 &&
                        AppInCurrentStateCount(appBundle, currentState.STATE_WAITING_TO_DOWNLOAD) == 0 &&
                        AppInCurrentStateCount(appBundle, currentState.STATE_DOWNLOADING) == 0 &&
                        AppInCurrentStateCount(appBundle, currentState.STATE_INSTALLING) == 0 &&
                        AppInCurrentStateCount(appBundle, currentState.STATE_WAITING_TO_INSTALL) == 0
                        )
                    {
                        AppInCurrentStateCount(appBundle, currentState.STATE_WAITING_TO_INSTALL);
                        return;
                    }
                }
                Thread.Sleep(500);
            }
        }