【发布时间】:2015-11-19 22:38:14
【问题描述】:
我无法调用我的异步方法...我想调用该方法,以便可以使用该方法内部变量中的值。 注意:ViewDetailsAsync 来自网络服务。
这就是我所拥有的:
namespace TilesAndNotifications.Models
{
public class PrimaryTile
{
public async void GetTileData()
{
ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
string name= string.Empty;
string description = string.Empty;
string type= string.Empty;
var res = await client.ViewDetailsAsync();
name= res.NameView;
description = res.DescriptionView;
type= res.TypeView;
}
public string CurrentName { get; set; } = "John Doe";
public string CurrentDescription { get; set; } = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.";
public string CurrentType { get; set; } = "Employee";
}
}
我想完成什么
public string CurrentName { get; set; } = GetTileData.name;
public string CurrentDescription { get; set; } = GetTileData.description
public string CurrentType { get; set; } = GetTileData.type;
但我不确定从异步方法中获取该信息...我知道这可能是初级的,但我似乎无法得到它。
【问题讨论】:
-
来自“public async void GetTileDate()”....
-
Never do
async void除非您正在编写事件处理程序。 -
你让每个人都感到困惑。您之前的帖子有一个 xml 文档。这个帖子的人不知道。此外,您之前发布的 xml 没有 3 个属性 CurrentName、CurrentDescription 和 CurrentType。请发布包含这三个属性的正确 XML。
-
因为我改了,所以新问题
标签: c# wcf asynchronous