Exemple #1
0
 // Implementation of ISearchCompletedCallback interface...
 public void Invoke(ISearchJob searchJob, ISearchCompletedCallbackArgs e)
 {
     // !!! warning this function is invoced from a different thread !!!
     agent.mDispatcher.Invoke(new Action(() => {
         agent.OnUpdatesFound(searchJob);
     }));
 }
Exemple #2
0
        //------ WUA callbacks ----------------------------------------------------

        //Search Complete callback

        //for now this will be our callback
        //This needs some testing because can be problematic accorting to:
        //https://docs.microsoft.com/en-us/windows/win32/wua_sdk/guidelines-for-asynchronous-wua-operations
        void ISearchCompletedCallback.Invoke(ISearchJob searchJob, ISearchCompletedCallbackArgs callbackArgs)
        {
            try
            {
                var searchResult = updateSearcher.EndSearch(searchJob);

                if (searchResult.ResultCode != OperationResultCode.orcSucceeded && searchResult.ResultCode != OperationResultCode.orcSucceededWithErrors)
                {
                    DebugLog($"Update search failed with code: {searchResult.ResultCode}");
                    CheckCompleted?.Invoke(false);
                    return;
                }

                DebugLog($"Found {searchResult.Updates.Count} updates:" + Environment.NewLine);

                foreach (IUpdate update in searchResult.Updates)
                {
                    DebugLog(Dump(update));
                }

                DebugLog($"There are {searchResult.RootCategories.Count} cateories:" + Environment.NewLine);

                foreach (ICategory category in searchResult.RootCategories)
                {
                    DebugLog(Dump(category));
                }


                if (searchResult.Updates.Count > 0)
                {
                    updateCollection = searchResult.Updates;


                    foreach (IUpdate update in updateCollection)
                    {
                        List <string> KBs = new List <string>();
                        foreach (string KB in update.KBArticleIDs)
                        {
                            KBs.Add(KB);
                        }

                        WinUpdateStatus updateStatus = new WinUpdateStatus(update.Title, KBs);
                        updateResults.Add(update.Title, updateStatus);
                    }

                    UpdatesFound?.Invoke();
                    CheckCompleted?.Invoke(true);
                }
                else
                {
                    CheckCompleted?.Invoke(false);
                }
            }
            catch (Exception ex)
            {
                CheckCompleted?.Invoke(false);
                Log.Error("ISearchCompletedCallback.Invoke", ex.ToString());
            }
        }
Exemple #3
0
        /// <summary>
        /// Used by the windows update api. Do not call this method.
        /// </summary>
        void Invoke(ISearchJob searchJob, ISearchCompletedCallbackArgs callbackArgs)
        {
            bool doCallback = false;

            lock (JobLock)
            {
                if (Job != null && Job.InternalJobObject == searchJob && Job.IsCompleted)
                {
                    StopTimeoutTimer();
                    doCallback = true;
                }
            }
            // calling the callback inside the lock can lead to deadlocks when the callback tries to dispose this object
            if (doCallback)
            {
                _completedCallback(_searcher.EndSearch(searchJob));
            }
        }
 public void Invoke(ISearchJob searchJob, ISearchCompletedCallbackArgs callbackArgs)
 {
     WindowsUpdateFrame.sResult = WindowsUpdateFrame.uSearcher.EndSearch(WindowsUpdateFrame.searchJob);
     WindowsUpdateFrame.Dispatcher.BeginInvoke(new Action(() => WindowsUpdateFrame.textBox1.Text = "Found " + WindowsUpdateFrame.sResult.Updates.Count + " updates" + Environment.NewLine));
     foreach (IUpdate update in WindowsUpdateFrame.sResult.Updates)
     {
         WindowsUpdateFrame.Dispatcher.BeginInvoke(new Action(() => WindowsUpdateFrame.textBox1.AppendText(update.Title + Environment.NewLine)));
     }
     WindowsUpdateFrame.downloadJob = null;
     if (WindowsUpdateFrame.sResult.Updates.Count != 0)
     {
         WindowsUpdateFrame.Dispatcher.BeginInvoke(new Action(() => WindowsUpdateFrame.InstallButton.IsEnabled = true));
     }
     else
     {
         SetWinServices.DisableWinService("wuauserv");
         SetWinServices.Disable("wuauserv");
     }
 }
Exemple #5
0
 // Implementation of IDownloadCompletedCallback interface...
 public void Invoke(ISearchJob searchJob, ISearchCompletedCallbackArgs e)
 {
     form1.iUpdateSearchComplete(this.form1);
 }
 public void Invoke(ISearchJob searchJob, ISearchCompletedCallbackArgs callbackArgs)
 {
     this.CompleteTask();
     ServiceEventSource.Current.InfoMessage("Callback: Searching of Windows Updates completed.");
 }
Exemple #7
0
 // Implementation of IDownloadCompletedCallback interface...
 public void Invoke(ISearchJob searchJob, ISearchCompletedCallbackArgs e)
 {
     form1.SearchUpdateComplete(this.form1);
 }
Exemple #8
0
 public void Invoke(ISearchJob searchJob, ISearchCompletedCallbackArgs callbackArgs)
 {
     EndSearch(searchJob);
 }
 public void Invoke(ISearchJob searchJob, ISearchCompletedCallbackArgs callbackArgs)
 {
     //Update is completed!
     m_called = true;
 }
 public void Invoke(ISearchJob searchJob, ISearchCompletedCallbackArgs callbackArgs) => Action?.Invoke(searchJob, callbackArgs);
 public void Invoke(ISearchJob searchJob, ISearchCompletedCallbackArgs callbackArgs)
 {
     Job          = searchJob;
     SearchResult = UpdateSearcher.EndSearch(searchJob);
 }
Exemple #12
0
 public void Invoke(ISearchJob searchJob, ISearchCompletedCallbackArgs callbackArgs) => _state.Invoke(searchJob, callbackArgs);
        public void Invoke(ISearchJob searchJob, ISearchCompletedCallbackArgs callbackArgs)
        {
            ISearchResult result = _updateSearcher.EndSearch(searchJob);

            _taskCompletionSource.SetResult(result);
        }