[Ironruby-core] .NET delegates, asynchronousness and such

Ivan Porto Carrero ivan at flanders.co.nz
Thu Jun 19 23:20:22 EDT 2008


I want to execute a delegate asynchronously with something like
Action.BeginInvoke that doesn't seem to work, also using BackgroundWorker I
get no result.

bw = System::ComponentModel::BackgroundWorker.new
bw.do_work { #do some work here, but never seems to get executed }

in C# public delegate void VoidHandler();
in IronRuby: VoidHandler.new{ #do some work her, but never seems to get
executed }.begin_invoke(nil, nil)

VoidHandler.new{ File.open('threading.txt', 'w'){ |f| f << "writing from
thread" } }.begin_invoke(nil, nil)

never creates the file threading.txt

But using the ThreadPool myself does work properly and creates a file

>>> $cb = WaitCallback.new { File.open("threading2.txt" , 'w'){|f| f <<
"From Thread" }
=> #<System::Threading::WaitCallback:0x0000066>
>>> System::Threading::ThreadPool.queue_user_work_item $cb, nil
=> true

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080620/5667b813/attachment-0001.html>

More information about the Ironruby-core mailing list