我正在使用wcf执行插入数据的任务。我正在使用wcf void函数之一插入用户数据

AceVqbzServiceClient aceVqbzClientService = new AceVqbzServiceClient();
aceVqbzClientService.OpenAsync();
IAceVqbzService aceVqbzTypeService = aceVqbzClientService as IAceVqbzService;

Task.Factory.FromAsync(
            aceVqbzTypeService.BeginSaveUserOrganizationLinking,
            aceVqbzTypeService.EndSaveUserOrganizationLinking,
            objUser_OrganizationDetail,
            TaskCreationOptions.None);

aceVqbzClientService.CloseAsync();


这是功能

我使用时功能没有出现任何问题,但数据没有通过此插入。
请给我解决方案,以便我可以实施

最佳答案

您需要异步等待(使用await)从Task返回的FromAsync

public async Task FooAsync()
{
    AceVqbzServiceClient aceVqbzClientService = new AceVqbzServiceClient();
    await aceVqbzClientService.OpenAsync();
    IAceVqbzService aceVqbzTypeService = aceVqbzClientService as IAceVqbzService;

    await Task.Factory.FromAsync(
                       aceVqbzTypeService.BeginSaveUserOrganizationLinking,
                       aceVqbzTypeService.EndSaveUserOrganizationLinking,
                       objUser_OrganizationDetail, TaskCreationOptions.None);

    await aceVqbzClientService.CloseAsync();
}

10-06 08:31