Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Asynchronous COM call

$
0
0

Calling a COM method (by using a supplied interop dll, rcw), but would like to call it asynchronously by making a service which expose asynchronously methods.
The COM methods are marshalled to another process (perhaps also another machine) and are long lasting.
Whenever the call within the asynchronously method is done, the caller of the async method is blocked.

How to make this service really asynchronously (i.e. calling method will NOT be blocked) ?

My example is similar to:

...

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            PerformTask();
            // This click event handler does not return until the server has finished and returned, i.e. the call is in fact synchronous
        }

        private async void PerformTask()
        {
            await SlowTask();
        }

        private async Task SlowTask()
        {
            TheCOMServer server = new TheCOMServer();
            server.DoSomethingLongLasting();
            return;
        }


Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>