小编Jen*_*ait的帖子

等待内部方法直到捕获事件

我在C#中遇到了这个问题.我做了一个方法,从一个dll调用一个函数,它被称为Phone.GetLampMode(); Now Phone.GetLampMode并不返回任何东西.在' onGetLampModeResponse'事件中返回数据.有没有办法可以在我的方法中等待,直到我从onGetLampModeResponse事件中获取数据?

public bool checkLamp(int iLamp)
{
    Phone.ButtonIDConstants btn = new Phone.ButtonIDConstants();
    btn = Phone.ButtonIDConstants.BUTTON_1;
    btn += iLamp;
    Phone.GetLampMode(btn, null);

    return true;
}

private void Phone_OnGetLampModeResponse(object sender, Phone.GetLampModeResponseArgs e)
{
    var test = e.getLampModeList[0].getLampMode.ToString();    
}
Run Code Online (Sandbox Code Playgroud)

c# events wait

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1

events ×1

wait ×1