Ivan Porto Carrero
2008-Jun-20 03:20 UTC
[Ironruby-core] .NET delegates, asynchronousness and such
Hi
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)
So
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
threading2.txt
>>> $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
Thanks
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/ironruby-core/attachments/20080620/5667b813/attachment-0001.html>