Async Callbacks .NET and ABL - is it possible?

Posted by dmci2309 on 21-Oct-2012 00:55

Hi All,

I'm working on a program that can receive messages from MSMQ using .NET libraries (see original thread

I have developed a simple sender, single receiver and polling receiver programs. All working great.

I'm currently working on an asynchrous receiver that *hopefully* will process messages as they arrive in the queue - using callbacks. I'm trying to convert the C sample code in into ABL - as a starting point.

The 'BeginReceive' method requires the AsyncCallBack class which is the method to call when a message arrives on the queue. This has one parameter (according to the sample)

 // Begin the asynchronous receive operation.
 queue.BeginReceive(TimeSpan.FromSeconds(10.0), messageNumber++,
    new AsyncCallback(MyReceiveCompleted));

However when I try to use that same method in ABL (OE 11.0), I get a compile error, Progress expects 2 parameters not one.

    /* 10 seconds */
    loTimeSpan = new System.TimeSpan(0,0,10).
    loAsyncCallBack = new System.AsyncCallback("MyReceiveCompleted").   /* Progress complains that 2 parameters are required */

Searching for the constructor for 'AsyncCallback', I find out that it is a delegate (not sure what that is) -

What also caught my attention (in the above URL) was this statement:

Use an AsyncCallback delegate to process the results of an asynchronous operation in a separate thread.

Sooooo, I wondering whether I can do this in ABL? Is it possible? If so, some pointers would be greatly appreciated.

I know with SonicMQ - via ABL - that you can use the methods Progress provides (string name of the call back procedure and a handle as to where that procedure is located) to do this. I am assuming something similar will be needed for .NET, just not sure how to do that!

Many thanks


All Replies

Posted by Admin on 21-Oct-2012 12:23

The ABL does not support delegates. Progress has implemented Events as the only way .NET may call into the ABL.

In similar use cases, I've written a wrapper Assembly in C#, handled they async wait in a separate thread, synchronized the delegate method into the UI thread and raised an event there which was subscribed by an ABL method.

This thread is closed