繁体   English   中英

无法调用EventHandler

[英]Can't Invoke EventHandler

嗨,我有一个名为GetString的WCF服务方法,我将其称为Windows Phone App,为此,我使用了无法调用的EventHandler。这是我的示例代码,

private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        MobileService1.Service1Client x = new MobileService1.Service1Client();
        x.GetStringAsync();
        x.GetStringCompleted += new EventHandler<MobileService1.GetStringCompletedEventArgs>(x_GetStringCompleted);
    }

 private void x_GetStringCompleted(object sender, MobileService1.GetStringCompletedEventArgs e)
    {
        MessageBox.Show(e.Result);
    }

这个x_GetStringCompleted没有被调用,请Plz帮助Folks ...

您不应为服务使用局部变量。 大概在Button_Click_1方法结束之前没有完成对服务的调用。 因此,您的服务实例以及因此完成的委托可能在异步调用完成之前就消失了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM