<div dir="ltr">2nd attempt at defining the problem:<br>"problem assigning bound method to delegate?"<br>that's my last try. now someone who actually has a clue needs to look at it :-)<br><br><div class="gmail_quote">
On Mon, Sep 22, 2008 at 3:29 PM, Ronnie Maor <span dir="ltr"><<a href="mailto:ronnie.maor@gmail.com">ronnie.maor@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">I think this is a bug and not some silly mistake on my part...<br>not sure exactly which flows this effects, but here is a small repro:<br><br>import System.Threading<br><br>def cb(state):<br> print "CB CALLED"<br>
<br>class Timer(object):<br> def __init__(self,delay,interval): <br> def _inner_cb(state):<br> print "INNER CALLED"<br> self._callback(None)<br> f = self._callback # this is the problematic variant<br>
#f = cb<br> #f = _inner_cb<br><br> self.timer = System.Threading.Timer(f,None,delay,interval)<br> <br> def _callback(self,state): # state parameter is required as part of TimerCallback signature. ignore it.<br>
print "CALLBACK CALLED"<br><br>t = Timer(1000,0)<br>print "Sleeping..."<br>System.Threading.Thread.CurrentThread.Join(2000)<br>print "Woke up"<br><br>------------------ (end code)<br>
<br>C:\IronPython\2.0\IronPython-2.0B5>ipy \data\trunk\src\Itst.Backend\tmp.py<br>Traceback (most recent call last):<br> File "\data\trunk\src\Itst.Backend\tmp.py", line 20, in \data\trunk\src\Itst.Backend\tmp.py<br>
File "\data\trunk\src\Itst.Backend\tmp.py", line 15, in __init__<br>TypeError: Value cannot be null.<br>Parameter name: context<br><br>The code works when you change f to one of the other variants (cb or _inner_cb).<br>
For now I'm going to use _inner_cb variant as a workaround so I can continue porting my code and map other issues.<br><br>one note if/when comparing with IPy 1.1. The overload resolution was not as good there, so you need to change the call to Timer to:<br>
Timer_ctor = System.Threading.Timer.__new__.Overloads[(System.Threading.TimerCallback,object,int,int)]<br> self.timer = Timer_ctor(System.Threading.Timer,f,None,delay,interval)<br><br></div>
</blockquote></div><br></div>