Hi there, I know that I can register and handle .Net events in IronRuby in the following way: klass.some_event { |sender, args| puts "Hello!" } Is this the only way of doing so or are there more ways? Thanks! Shay. ---------------------------- Shay Friedman http://www.ironshay.com Follow me: http://twitter.com/ironshay -- Posted via http://www.ruby-forum.com/.
Quite similarly you can send a Proc as the event value: http://github.com/thbar/magic/blob/fd51bcd6f4c713fdb8b4bbb60b1c18ca84804c3a/lib/magic/instance_creator.rb#L50 Hth, -- Thibaut Le 11 juil. 2009 ? 17:17, Shay Friedman <lists at ruby-forum.com> a ?crit :> Hi there, > > I know that I can register and handle .Net events in IronRuby in the > following way: > klass.some_event { |sender, args| puts "Hello!" } > > Is this the only way of doing so or are there more ways? > > Thanks! > Shay. > ---------------------------- > Shay Friedman > http://www.ironshay.com > Follow me: http://twitter.com/ironshay > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core
These and any future changes will be in the specs at Merlin/Main/Languages/Ruby/Tests/Interop/net/events Sent from my Windows? phone. build 21215.5.0.0 -----Original Message----- From: thibaut.barrere at gmail.com <thibaut.barrere at gmail.com> Sent: Saturday, July 11, 2009 10:39 AM To: ironruby-core at rubyforge.org <ironruby-core at rubyforge.org> Cc: ironruby-core at rubyforge.org <ironruby-core at rubyforge.org> Subject: Re: [Ironruby-core] .Net Events in IR Quite similarly you can send a Proc as the event value: http://github.com/thbar/magic/blob/fd51bcd6f4c713fdb8b4bbb60b1c18ca84804c3a/lib/magic/instance_creator.rb#L50 Hth, -- Thibaut Le 11 juil. 2009 ? 17:17, Shay Friedman <lists at ruby-forum.com> a ?crit :> Hi there, > > I know that I can register and handle .Net events in IronRuby in the > following way: > klass.some_event { |sender, args| puts "Hello!" } > > Is this the only way of doing so or are there more ways? > > Thanks! > Shay. > ---------------------------- > Shay Friedman > http://www.ironshay.com > Follow me: http://twitter.com/ironshay > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > 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
Shay Friedman wrote:> Hi there, > > I know that I can register and handle .Net events in IronRuby in the > following way: > klass.some_event { |sender, args| puts "Hello!" } > > Is this the only way of doing so or are there more ways? > > Thanks! > Shay. > ---------------------------- > Shay Friedman > http://www.ironshay.com > Follow me: http://twitter.com/ironshayWhat are you looking to do currently, is there something specific you want to accomplish? You are sending a block, so this could be multi-line with do/end . Also, (depending on the context of your program), you could forgo the |sender, args| : button.click do puts "Something..." puts "Very interesting.." end I''ve attached a very simple Windows Forms app which shows this method of hooking up an event, firing it manually through code, and then bringing up the GUI... -- Posted via http://www.ruby-forum.com/.
I couldn''t attach the specified file, as the forum would give me an Application Error, will try to send to Shay directly.. Please feel free to direct message me if anyone else comes across this and wants a copy of the file. Otherwise, I''d suggest a better resource for writing windows apps with IronRuby is Thibaut Barr?re''s "magic": http://github.com/thbar/magic/tree/master -- Posted via http://www.ruby-forum.com/.
Robert Brotherus
2009-Jul-13 10:01 UTC
[Ironruby-core] Accessing 32-bit native DLL:s when running IR on Vista64
We are building IronRuby top-layer on a legacy application that consist, in part, of Windows 32-bit native dll:s. These native DLL:s are accessed by C# code via P/Invoke and our IronRuby code subsequently calls the C# code. We start our app by running: ie.exe main.rb Things are going fine on Windows XP/Vista 32-bit. On 64-bit Vista, the native DLL:s fail to load and application execution fails. This is because 64-bit Vista uses by default 64-bit version of MS.NET framework (in c:\Windows\Microsoft.NET\Framework64). This executes in a 64-bit process that cannot load 32-bit dll:s. Vista64 has also 32-bit version of ms.net (in c:\Windows\Microsoft.NET\Framework). When our app is run with this version of the framework, it executes fine (loading 32-bit native dll:s) on Vista64. However, the only way we have found out to run a dotnet-exe with the 32-bit dotnet-framework on Vista64 is to compile the dotnet-exe with having "Platfowm target"-setting to be "x86" instead of the default "Any CPU". This means that currenlty we are forced to use our own compilation of ir.exe instead of working with the out-of-the-box ironruby-installations at http://www.ironruby.net/Download. Is there a way to start a dotnet-exe that has been built with "Any CPU" setting explicitly with 32-bit version of dotnet framework? Something like: c:\work> launch32 ir.exe main.rb If no, would it make sense for ir installation packages to contain out-of-the-box three versions of the main exe: ie.exe (Any CPU), ir32.exe and ir64.exe ? Robert Brotherus Napa Inc.
Shri Borde
2009-Jul-13 18:30 UTC
[Ironruby-core] Accessing 32-bit native DLL:s when running IR on Vista64
Its trivial to implement "launch32". Just use AppDomain.ExecuteAssembly (http://msdn.microsoft.com/en-us/library/system.appdomain.executeassembly.aspx) to launch ir.exe in the same process. Now the launch32.exe wrapper program needs to be compiled using /platform:x86. The bitness of the process will be determined by the bitness of launch32.exe, not any exes it launches in-process using ExecuteAssembly. That said, it *will* be useful to include platform-specific versions of ir.exe in the release. F# does this, and IronPython has recently started doing this. The main reason to do this is that startup is very slow on 64-bit machines. See http://stackoverflow.com/questions/1015076/why-is-ironpython-startup-time-so-slow. So having ir.exe be a 32-bit executable prevents people from naively hitting the slow startup, while including ir64.exe still enables the folks who need 64-bit processes (mainly because they are manipulating large data sets and need more than 2^32 address space) Thanks, Shri -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Robert Brotherus Sent: Monday, July 13, 2009 3:02 AM To: ironruby-core at rubyforge.org Subject: [Ironruby-core] Accessing 32-bit native DLL:s when running IR on Vista64 We are building IronRuby top-layer on a legacy application that consist, in part, of Windows 32-bit native dll:s. These native DLL:s are accessed by C# code via P/Invoke and our IronRuby code subsequently calls the C# code. We start our app by running: ie.exe main.rb Things are going fine on Windows XP/Vista 32-bit. On 64-bit Vista, the native DLL:s fail to load and application execution fails. This is because 64-bit Vista uses by default 64-bit version of MS.NET framework (in c:\Windows\Microsoft.NET\Framework64). This executes in a 64-bit process that cannot load 32-bit dll:s. Vista64 has also 32-bit version of ms.net (in c:\Windows\Microsoft.NET\Framework). When our app is run with this version of the framework, it executes fine (loading 32-bit native dll:s) on Vista64. However, the only way we have found out to run a dotnet-exe with the 32-bit dotnet-framework on Vista64 is to compile the dotnet-exe with having "Platfowm target"-setting to be "x86" instead of the default "Any CPU". This means that currenlty we are forced to use our own compilation of ir.exe instead of working with the out-of-the-box ironruby-installations at http://www.ironruby.net/Download. Is there a way to start a dotnet-exe that has been built with "Any CPU" setting explicitly with 32-bit version of dotnet framework? Something like: c:\work> launch32 ir.exe main.rb If no, would it make sense for ir installation packages to contain out-of-the-box three versions of the main exe: ie.exe (Any CPU), ir32.exe and ir64.exe ? Robert Brotherus Napa Inc. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core