简体   繁体   English

无法调用EventHandler

[英]Can't Invoke EventHandler

Hi I 've an WCF Service Method named GetString, I've to call it Windows Phone App, For that I'm using a EventHandler that cant be invoked.. Here is my sample code, 嗨,我有一个名为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);
    }

This x_GetStringCompleted is not invoked, Plz help Folks... 这个x_GetStringCompleted没有被调用,请Plz帮助Folks ...

You shouldn't use a local variable for your service. 您不应为服务使用局部变量。 Presumably the call to the service isn't done before the end of the Button_Click_1 method. 大概在Button_Click_1方法结束之前没有完成对服务的调用。 So your service instance and therefore the completed delegate might be gone before the async call has finished. 因此,您的服务实例以及因此完成的委托可能在异步调用完成之前就消失了。

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

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