<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Where&#8217;d the call to Console.ReadLine go?&nbsp; That&#8217;s
the reason you don&#8217;t see Finished printing&#8230;&nbsp; On 1.1 and 2.0B2 from
the console or in a file w/ a call to Console.ReadLine or raw_input I end up
seeing finished getting printed.&nbsp; We&#8217;re simply exiting before the asynchronous
operation but that doesn&#8217;t fully answer the question &#8211; started is
still never printing!&nbsp; Stranger yet you can call mi() directly showing the
delegate is clearly created correctly and working.&nbsp; Anyway, I&#8217;ll
have to look at it closer &#8211; it might require windbg to figure out what&#8217;s
going wrong here.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b>On
Behalf Of </b>Matthew Barnard<br>
<b>Sent:</b> Tuesday, May 13, 2008 5:39 PM<br>
<b>To:</b> IronPython List<br>
<b>Subject:</b> [IronPython] System.Windows.Forms.MethodInvoker<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>The C# sample runs as expected, displaying 'Started.
Finished.', but the ipy does nothing.<br>
Can someone enlighten me as to the difference? I assume it is something to do
with the way functions are represented in ipy vs. what methodinvoker is looking
for,<br>
but I'm honestly lost.<br>
<br>
<span style='color:#3333FF'>C#:<br>
<br>
class foo<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public void start()<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Console.WriteLine(&quot;Started.&quot;);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Thread.Sleep(2000);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public void finish(IAsyncResult r)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
Console.WriteLine(&quot;Finished.&quot;);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; class Program<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; static void Main(string[] args)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; foo bar = new foo();<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; MethodInvoker mi = new
MethodInvoker(bar.start);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mi.BeginInvoke(new
AsyncCallback(bar.finish), null);<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Console.ReadLine();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }</span><br>
<br>
<br>
<span style='color:#009900'>IPY:<br>
<br>
import clr<br>
<br>
clr.AddReferenceByPartialName('System.Windows.Forms')<br>
<br>
from System import AsyncCallback<br>
from System.Threading import Thread<br>
from System.Windows.Forms import MethodInvoker<br>
<br>
class foo:<br>
&nbsp;&nbsp;&nbsp; def start(self):<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print 'Started.'<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Thread.Sleep(2000)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; def finish(self, r):<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print 'Finished.'<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
bar = foo()<br>
mi = MethodInvoker(bar.start)<br>
mi.BeginInvoke(AsyncCallback(bar.finish), None)<br>
</span><br>
<br>
___________________________<br>
Matthew Barnard<o:p></o:p></p>

</div>

</body>

</html>