old amd callback object disappare in 3.7.2

ggslayerggslayer MingYi ZhangOrganization: renren.comProject: renren data platformMember
edited July 11 in Help Center

in 3.7.2, c# server side slice-generated code changed, from older "amd parameter" to the new task mode, I can't find the amd parameter from the parameter list in method.

in my usage expirence of amd, it is useful like this:

void (...amd  callback, int para1, int para2)
{
    // do something must sync
    // ex:  write to db

    // give client response first
    callback.ice_response();

    // do something async
    // ex: send a mq message or something longtime job
}

now, with the new async mode in c#, how this can be done?

Tagged:

Answers

  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff
    edited July 11
    public override Task<string> opStringAsync(Ice.Current current)
    {
        // do something must sync
        // ex:  write to db
        return Task<string>.Run(() =>
            {
                   // do something async
                    // ex: send a mq message or something longtime job
                    return "hello world!";
             });
    }
    

    Or simpler using async/await

    public override async Task<string> opStringAsync(Ice.Current current)
    {
         // do something must sync
         // ex:  write to db
    
         // await the async operation
         await xxxAsync();
         return "hello world!";
    }
    

    See AMD Tasks in C#

Sign In or Register to comment.