可能因为GC资源释放而无法调用’已完成’事件处理程序?
public void StartVideo(WerCamera camera)
{
Credential creadential = new Credential() { Email = CurrentUser.Email, Password = CurrentUser.Password, SessionNumber = SessionNumber};
CommandsClient client = new CommandsClient();
client.StartVideoCompleted += client_StartVideoCompleted;
client.StartVideoAsync(int.Parse(camera.Id), creadential, ClientInfo);
client.CloseAsync();
}
最佳答案 是的,这是可能的,因为一旦函数返回,您将丢失对客户端的所有引用.
client.StartVideoCompleted = client_StartVideoCompleted;最终使用client_StartVideoCompleted函数保持对该对象的引用,但这不是往复的.您需要以某种方式保持对创建的客户端的引用.