带回调的.net Web服务调用

时间:2015-09-04 07:10:56

标签: c# .net web-services

有谁知道如何发送"回调"对Web服务进行排序的参数,以便在完成某个操作时,Web服务可以调用回调,而不返回该操作的值。

例如,进度百分比,或更类似于我的问题:

  • 你有3个水果(苹果,橘子和柠檬)
  • 你询问有关所有水果的信息(3种水果)

我希望Web服务在知道每个水果的答案后立即返回每个值,但也保持在同一个动作调用中,因此我没有记录大量不同调用的问题(在实际上,有3个以上的成果),因为客户与日志记录的某些方面相互作用,这可能会非常混乱

 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
    }

谢谢

1 个答案:

答案 0 :(得分:0)