none
Apply Timeout to Search Pending Windows Update RRS feed

  • Question

  • Hi Guys,

    I am trying to build system where it finds pending updates for the system using below code.

    var session = new UpdateSession();
    var searcher = session.CreateUpdateSearcher();
    var searchType = "Type='Software' and IsInstalled =0";
    searcher.Online = false;
    var searchResult = searcher.Search(searchType);

    Sometime Microsoft Search takes lot more time, So wanted to add TimeOut after which it stop trying to fetch data of updates.

    Is there a way for doing it?.

    P.S : Not sure this is write category where i am posting it, as new to it. Please redirect to correct post if it's wrong.
    Wednesday, November 16, 2016 1:45 PM

Answers

  • Not really.  The COM object only times out on no results.  As long as it is finding results you have to wait.

    If you use a compiled language like C# or use PowerShell you can use BeginSeach and EndSearch along with a callback to check time.


    \_(ツ)_/

    • Marked as answer by Patch Tech Thursday, November 17, 2016 7:39 AM
    Wednesday, November 16, 2016 6:28 PM

All replies

  • Not really.  The COM object only times out on no results.  As long as it is finding results you have to wait.

    If you use a compiled language like C# or use PowerShell you can use BeginSeach and EndSearch along with a callback to check time.


    \_(ツ)_/

    • Marked as answer by Patch Tech Thursday, November 17, 2016 7:39 AM
    Wednesday, November 16, 2016 6:28 PM
  • Okay Thanks.

    This has made my life difficult.

    Need to check workaround.

    We do coding in VB.

    Please let me know if any workaround you can think of.
    Thursday, November 17, 2016 7:39 AM
  • This is not a VB forum.  You need to post in the VB forum for assistance.

    \_(ツ)_/

    Thursday, November 17, 2016 8:13 AM