Hello Is it possible to call the Control.Dispatcher.Invoke in IronRuby? I have been digging around and trying various approaches for quite a while and can''t quite seem to get it to work. The most simple example I below where I do not even access the parameter fails... any ideas would be greatly appreciated. class MainWindow < Window def updateStatus(status) puts ''hi'' end def initialize self.Dispatcher.Invoke(updateStatus, ["jo"]) end end Thanks for your time and ideas, Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091124/690a43ba/attachment.html>
Yes it is possible but you need to wrap it in a Delegate like Action for it to work A ruby method is not a CLR delegate at all. So you can do something like this def update_status(status) puts status end def initialize meth = proc { |st| update_status(st) } self.dispatcher.invoke meth, %w(jo) end --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Google Wave: portocarrero.ivan at googlewave.com Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Tue, Nov 24, 2009 at 7:44 PM, Patrick Brown <patrickcbrown at gmail.com>wrote:> Hello > > Is it possible to call the Control.Dispatcher.Invoke in IronRuby? I > have been digging around and trying various approaches for quite a while and > can''t quite seem to get it to work. The most simple example I below where I > do not even access the parameter fails... any ideas would be greatly > appreciated. > > class MainWindow < Window > def updateStatus(status) > puts ''hi'' > end > > def initialize > self.Dispatcher.Invoke(updateStatus, ["jo"]) > end > end > > Thanks for your time and ideas, > Patrick > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091124/ab43d863/attachment-0001.html>
sorry def initialize meth = proc { |st| update_status(st) } self.dispatcher.invoke(System::Action.new(&meth), %w(jo)) end http://github.com/casualjim/ironnails/blob/master/IronNails/vendor/iron_nails/lib/view/xaml_proxy.rb#L10 --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Google Wave: portocarrero.ivan at googlewave.com Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Tue, Nov 24, 2009 at 7:44 PM, Patrick Brown <patrickcbrown at gmail.com>wrote:> Hello > > Is it possible to call the Control.Dispatcher.Invoke in IronRuby? I > have been digging around and trying various approaches for quite a while and > can''t quite seem to get it to work. The most simple example I below where I > do not even access the parameter fails... any ideas would be greatly > appreciated. > > class MainWindow < Window > def updateStatus(status) > puts ''hi'' > end > > def initialize > self.Dispatcher.Invoke(updateStatus, ["jo"]) > end > end > > Thanks for your time and ideas, > Patrick > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091124/025aa3f5/attachment.html>
Hi Thanks for your help, it still seems to be a bit off, I get this message after I cut and pasted your code in. Still looking into it but not finding much... ./MainWindow.rb:56: can''t convert Proc into System::Delegate (TypeError) Thanks, Patrick On Tue, Nov 24, 2009 at 2:09 PM, Ivan Porto Carrero <ivan at flanders.co.nz>wrote:> Yes it is possible but you need to wrap it in a Delegate like Action for it > to work > > A ruby method is not a CLR delegate at all. > So you can do something like this > > def update_status(status) > puts status > end > > def initialize > meth = proc { |st| update_status(st) } > self.dispatcher.invoke meth, %w(jo) > end > > > --- > Met vriendelijke groeten - Best regards - Salutations > Ivan Porto Carrero > Blog: http://flanders.co.nz > Google Wave: portocarrero.ivan at googlewave.com > Twitter: http://twitter.com/casualjim > Author of IronRuby in Action (http://manning.com/carrero) > > > > On Tue, Nov 24, 2009 at 7:44 PM, Patrick Brown <patrickcbrown at gmail.com>wrote: > >> Hello >> >> Is it possible to call the Control.Dispatcher.Invoke in IronRuby? I >> have been digging around and trying various approaches for quite a while and >> can''t quite seem to get it to work. The most simple example I below where I >> do not even access the parameter fails... any ideas would be greatly >> appreciated. >> >> class MainWindow < Window >> def updateStatus(status) >> puts ''hi'' >> end >> >> def initialize >> self.Dispatcher.Invoke(updateStatus, ["jo"]) >> end >> end >> >> Thanks for your time and ideas, >> Patrick >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091124/10140019/attachment.html>
Hi Sorry, missed this response, it looks closer, I have to poke around for a bit, I am getting a missing method exception on Action.new. Thanks, Patrick On Tue, Nov 24, 2009 at 2:11 PM, Ivan Porto Carrero <ivan at flanders.co.nz>wrote:> sorry > > def initialize > meth = proc { |st| update_status(st) } > self.dispatcher.invoke(System::Action.new(&meth), %w(jo)) > end > > > http://github.com/casualjim/ironnails/blob/master/IronNails/vendor/iron_nails/lib/view/xaml_proxy.rb#L10 > > --- > Met vriendelijke groeten - Best regards - Salutations > Ivan Porto Carrero > Blog: http://flanders.co.nz > Google Wave: portocarrero.ivan at googlewave.com > Twitter: http://twitter.com/casualjim > Author of IronRuby in Action (http://manning.com/carrero) > > > > On Tue, Nov 24, 2009 at 7:44 PM, Patrick Brown <patrickcbrown at gmail.com>wrote: > >> Hello >> >> Is it possible to call the Control.Dispatcher.Invoke in IronRuby? I >> have been digging around and trying various approaches for quite a while and >> can''t quite seem to get it to work. The most simple example I below where I >> do not even access the parameter fails... any ideas would be greatly >> appreciated. >> >> class MainWindow < Window >> def updateStatus(status) >> puts ''hi'' >> end >> >> def initialize >> self.Dispatcher.Invoke(updateStatus, ["jo"]) >> end >> end >> >> Thanks for your time and ideas, >> Patrick >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091124/7467c686/attachment.html>
This works for me: require ''PresentationFramework'' require ''PresentationCore'' class MainWindow < System::Windows::Window def update_status(status) puts status end def initialize meth = proc { |status| update_status status } dispatcher.invoke System::Action.of(String).new(&meth), "jo" end end System::Windows::Application.new.run MainWindow.new --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Google Wave: portocarrero.ivan at googlewave.com Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Tue, Nov 24, 2009 at 8:56 PM, Patrick Brown <patrickcbrown at gmail.com>wrote:> Hi > > Thanks for your help, it still seems to be a bit off, I get this message > after I cut and pasted your code in. Still looking into it but not finding > much... > > ./MainWindow.rb:56: can''t convert Proc into System::Delegate (TypeError) > Thanks, > Patrick > > > > On Tue, Nov 24, 2009 at 2:09 PM, Ivan Porto Carrero <ivan at flanders.co.nz>wrote: > >> Yes it is possible but you need to wrap it in a Delegate like Action for >> it to work >> >> A ruby method is not a CLR delegate at all. >> So you can do something like this >> >> def update_status(status) >> puts status >> end >> >> def initialize >> meth = proc { |st| update_status(st) } >> self.dispatcher.invoke meth, %w(jo) >> end >> >> >> --- >> Met vriendelijke groeten - Best regards - Salutations >> Ivan Porto Carrero >> Blog: http://flanders.co.nz >> Google Wave: portocarrero.ivan at googlewave.com >> Twitter: http://twitter.com/casualjim >> Author of IronRuby in Action (http://manning.com/carrero) >> >> >> >> On Tue, Nov 24, 2009 at 7:44 PM, Patrick Brown <patrickcbrown at gmail.com >> > wrote: >> >>> Hello >>> >>> Is it possible to call the Control.Dispatcher.Invoke in IronRuby? I >>> have been digging around and trying various approaches for quite a while and >>> can''t quite seem to get it to work. The most simple example I below where I >>> do not even access the parameter fails... any ideas would be greatly >>> appreciated. >>> >>> class MainWindow < Window >>> def updateStatus(status) >>> puts ''hi'' >>> end >>> >>> def initialize >>> self.Dispatcher.Invoke(updateStatus, ["jo"]) >>> end >>> end >>> >>> Thanks for your time and ideas, >>> Patrick >>> >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >>> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091124/a7cb1d05/attachment-0001.html>
Ivan Thank you so much, you have been a great help, what slowed me down is that your current sample which works is actually a bit different than the previous two. Patrick On Tue, Nov 24, 2009 at 3:18 PM, Ivan Porto Carrero <ivan at flanders.co.nz>wrote:> This works for me: > > require ''PresentationFramework'' > require ''PresentationCore'' > > class MainWindow < System::Windows::Window > > def update_status(status) > puts status > end > > def initialize > meth = proc { |status| update_status status } > dispatcher.invoke System::Action.of(String).new(&meth), "jo" > end > end > > System::Windows::Application.new.run MainWindow.new > --- > Met vriendelijke groeten - Best regards - Salutations > Ivan Porto Carrero > Blog: http://flanders.co.nz > Google Wave: portocarrero.ivan at googlewave.com > Twitter: http://twitter.com/casualjim > Author of IronRuby in Action (http://manning.com/carrero) > > > > On Tue, Nov 24, 2009 at 8:56 PM, Patrick Brown <patrickcbrown at gmail.com>wrote: > >> Hi >> >> Thanks for your help, it still seems to be a bit off, I get this >> message after I cut and pasted your code in. Still looking into it but not >> finding much... >> >> ./MainWindow.rb:56: can''t convert Proc into System::Delegate (TypeError) >> Thanks, >> Patrick >> >> >> >> On Tue, Nov 24, 2009 at 2:09 PM, Ivan Porto Carrero <ivan at flanders.co.nz>wrote: >> >>> Yes it is possible but you need to wrap it in a Delegate like Action for >>> it to work >>> >>> A ruby method is not a CLR delegate at all. >>> So you can do something like this >>> >>> def update_status(status) >>> puts status >>> end >>> >>> def initialize >>> meth = proc { |st| update_status(st) } >>> self.dispatcher.invoke meth, %w(jo) >>> end >>> >>> >>> --- >>> Met vriendelijke groeten - Best regards - Salutations >>> Ivan Porto Carrero >>> Blog: http://flanders.co.nz >>> Google Wave: portocarrero.ivan at googlewave.com >>> Twitter: http://twitter.com/casualjim >>> Author of IronRuby in Action (http://manning.com/carrero) >>> >>> >>> >>> On Tue, Nov 24, 2009 at 7:44 PM, Patrick Brown < >>> patrickcbrown at gmail.com> wrote: >>> >>>> Hello >>>> >>>> Is it possible to call the Control.Dispatcher.Invoke in IronRuby? I >>>> have been digging around and trying various approaches for quite a while and >>>> can''t quite seem to get it to work. The most simple example I below where I >>>> do not even access the parameter fails... any ideas would be greatly >>>> appreciated. >>>> >>>> class MainWindow < Window >>>> def updateStatus(status) >>>> puts ''hi'' >>>> end >>>> >>>> def initialize >>>> self.Dispatcher.Invoke(updateStatus, ["jo"]) >>>> end >>>> end >>>> >>>> Thanks for your time and ideas, >>>> Patrick >>>> >>>> _______________________________________________ >>>> Ironruby-core mailing list >>>> Ironruby-core at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/ironruby-core >>>> >>>> >>> >>> _______________________________________________ >>> Ironruby-core mailing list >>> Ironruby-core at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/ironruby-core >>> >>> >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091124/54c7761d/attachment.html>