无法调用EventHandler

时间:2013-09-23 07:23:14

标签: c# wcf events windows-phone-8 event-handling

您好我有一个名为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帮助人...

1 个答案:

答案 0 :(得分:0)

您不应该为您的服务使用本地变量。据推测,在Button_Click_1方法结束之前,不会对服务进行调用。因此,在异步调用完成之前,您的服务实例以及完成的委托可能已经消失。

相关问题