简体   繁体   中英

.net web service call with callbacks

Does anyone know how to send a "callback" parameter of sorts to a web service, so that, when a certain action is completed, the web service can invoke the callback, without return a value from the action.

For example, a progress percentage, or more similar to my problem:

  • you have 3 fruits ( apples, oranges and lemons )
  • you ask information about all the fruits ( the 3 fruits )

I want the web service to return each value as soon as it knows the answer to each fruit, but also, remains in the same action call, so I don`t have the problem of logging a ton of different calls ( in reality, there are more than 3 fruits ), as the clients interact with certain aspect of the logging, and it can be very confusing

 static void ClientFunction()
    {
        WebServiceFunction(Letters.All);
    }
    static bool WebServiceFunction(Letters whatLetters)
    {

        bool checkA = whatLetters == Letters.A, checkB = whatLetters == Letters.B, checkC = whatLetters = Letters.C,
            checkAll = whatLetters == Letters.All;

        //async wrapped
        if(checkA || checkAll)
        {
            // do something A
            // and send the answer to the client as soon as it is known
        }

        //async wrapped
        if (checkB || checkAll)
        {
            // do something B
            // and send the answer to the client as soon as it is known
        }

        //async wrapped
        if (checkC || checkAll)
        {
            // find out something about c
            // and send the answer to the client as soon as it is known
        }



        // lets say this is a generic return value ( for whatever the service does)
        return true;

    }

    enum Letters
    {
        A,
        B,
        C,
        All
    }

Thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM