Schmottlach, Glenn wrote:
I've looked at the C# examples in MSDN but they don't appear to lend
themselves (at least with my limited experience in .NET) to an easy
implementation in IronPython due to the dynamic nature of the type
system in Python.
The example I looked at:
http://msdn.microsoft.com/en-us/library/h80ttd5f.aspx
declares a delegate type which seems difficult to do in IronPython, e.g.
C#
public delegate bool AsyncFactorCaller (
int number,
ref int primefactor1,
ref int primefactor2);
So what's the equivalent in IronPython?
Also, (out) parameters are passed by reference to BeginInvoke and
EndInvoke and it's not clear to me how to handle this in IronPython.
So, I suspect I'm missing something in order to get things working. What
I really need to see is a concrete IronPython example and I think things
would gel at that point. Could you offer such an example . . . Google
hasn't been helpful in this respect.
out parameters are handled by IronPython as extra return values - you
wrap your callback function in CallTarget0 and an AsyncCallback.
I hope this helps.
Michael
-----Original Message-----
From: users-boun...@lists.ironpython.com
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Michael Foord
Sent: Monday, May 04, 2009 4:33 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Making asynchronous calls in IronPython
Schmottlach, Glenn wrote:
Although I'm very comfortable with CPython, I'm new to IronPython and
the .NET framework. What I am looking for is sample code that shows
how to issue an asynchronous call from IronPython using the
BeginInvoke/EndInvoke mechanism of .NET.
I can't remember the usage off the top of my head - but usage from
IronPython is identical to usage from C#, so an MSDN example ought to
give you what you need.
All the best,
Michael
Currently, I'm playing around with GTK# and a D-Bus .NET
implementation (NDesk-DBus) that only provides synchronous proxy
methods for D-Bus services. I believe (please correct me if I'm wrong)
that I should be able to use the BeginInvoke/EndInvoke mechanism to
issue these blocking proxy requests asynchronously and be notified
(via a callback) when the method has completed.
My blocking proxy calls look something like this:
ret = /self/._proxy.TunerGetCurrentWaveBand(0)
where 'ret' returns the current waveband (AM, FM, etc..) and are
called from a button "clicked" delegate. I would rather not block the
GTK# dispatch loop while waiting for the reply from the service. Can
someone offer me any advice or provide a reference to sample code that
illustrates the basic concept from IronPython?
------------------------------------------------------------------------
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com