What do you mean by "set up asynchronous calls"?

If your get_settings method is a C# method using the IAsyncResult pattern, then 
you should be able to invoke it from IronRuby.
>From memory you can pass a ruby Proc in place of the AsyncCallback and it 
>should all work:

Example:

callback = lambda{ |asyncresult| puts data.end_get_settings(asyncresult) }
data.begin_get_settings("abc", callback, nil)

If you want to write your own asynchronous method not involving C# at all, then 
you can do that too. If that's the case, then all you really need to do is 
remember to call the block when you're done.

Example

def get_settings(&block)
   do_long_thing
   settings = 123
   block.call(settings)
end

In a real function you'd probably run the body of get_settings in another 
thread, but I won't go into how to do threading, as there may be other better 
ways depending on your situation.

Cheers


On 22/01/2010, at 11:58 AM, Randall Sutton wrote:

> Is there a way to setup asychronous calls in IronRuby.  I've used things like 
> WebClient.download_string_async, but I'm wondering if I can setup an async 
> using just IronRuby.
> 
> For example:
> @data.get_settings do |settings|
>       # do stuff after async call
> end
> 
> Where get_settings is an async method and it executes the block after it is 
> completed.
> 
> Thanks for any help,
> Randall
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core@rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core

_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to