Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#异步事件过程不触发_C#_Asynchronous - Fatal编程技术网

C#异步事件过程不触发

C#异步事件过程不触发,c#,asynchronous,C#,Asynchronous,我正在使用一个API,该API具有一些方法,这些方法在完成时通过事件过程异步调用。我可以执行这些方法,但事件过程似乎没有启动。注意:我昨天发布了一个类似的问题,但直到很久以后才发布代码。我希望有人能发现我哪里出了问题 public partial class Window1 : Window { ClientAppServer newServer= new ClientAppServer(); public Window1() { InitializeComponent();

我正在使用一个API,该API具有一些方法,这些方法在完成时通过事件过程异步调用。我可以执行这些方法,但事件过程似乎没有启动。注意:我昨天发布了一个类似的问题,但直到很久以后才发布代码。我希望有人能发现我哪里出了问题

public partial class Window1 : Window
{
ClientAppServer newServer= new ClientAppServer();

public Window1()
{
    InitializeComponent();

    //the event thats supposed to fire
     newServer.ReceiveRequest += ReadServerReply;
}


private void ReadServerReply(RemoteRequest rr)
{
    //this point is never reached
    MessageBox.Show("reading server reply");
    if ((rr.TransferObject) is Gateways)
    {
        MessageBox.Show("you have gateways!");
    }
}


private void login()
{
//API docs says this is an asynchronous call        
newServer.RetrieveCollection(typeof(Gateways), true);

}


private void button1_Click(object sender, RoutedEventArgs e)
{
    this.login();
}

它是哪种API?这可能会帮助我们解决问题

从您发布的代码来看,RetrieveCollection方法似乎与接收请求无关——它看起来不应该触发

根据建议,我假定您已经尝试在事件处理程序上设置断点。如果没有库的源代码,可以使用Reflector查看库正在做什么,并检查它是否应该触发事件


我还应该补充一点,我尝试将非GUI操作添加到事件过程中,例如创建文本文件,但这也不起作用。我认为事件根本没有发生。如果没有看到ClientAppServer的源代码,很难判断出是什么问题。有吗?从表面上看,这件事似乎没有被提起。