views:

136

answers:

1

I am working with an API that has some methods that are called asynchronously with an event procedure upon completion. I can execute the methods, but the event procedure does not seem to fire. NOTE: I posted a similar question yesterday but didn't post the code until much later. I'm hoping someone can spot where I am going wrong

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();
}
+1  A: 

Which API is it? That might help us work it out.

From the code you've posted, it doesn't look like the RetrieveCollection method has anything to do with receiving requests - it doesn't look like it should fire.

In terms of advice, I'm presuming that you've tried setting a breakpoint on the event handler. If you don't have source code for your library, you could use Reflector to see what your library is doing and check whether it should fire the event.

http://www.red-gate.com/products/reflector/

Dan