D
Dolazy
I am developing a small GUI application using jruby. It will be used
for testing API calls to my company's server. I would like my
application to execute server calls in a non-blocking way. In C++ I do
this by creating a worker thread that executes the call and then
invokes a postback to the main thread (similar to Java's InvokeLater).
How do I do this in Ruby?
My simplified code looks something like this:
def get_users
Thread.new(server, successCallback, errorCallback) do |server, scb,
ecb|
res = Net::HTTP.post_form(server, { "action" => "getUsers"})
if res.body
scb.call(res.body) # => this should be wrapped in some sort of
InvokeLater ?
else
ecb.call("getUsers failed") # => this too
end
end
end
I would prefer to use the Ruby standard library over the Java library.
Eager to learn,
Francis
for testing API calls to my company's server. I would like my
application to execute server calls in a non-blocking way. In C++ I do
this by creating a worker thread that executes the call and then
invokes a postback to the main thread (similar to Java's InvokeLater).
How do I do this in Ruby?
My simplified code looks something like this:
def get_users
Thread.new(server, successCallback, errorCallback) do |server, scb,
ecb|
res = Net::HTTP.post_form(server, { "action" => "getUsers"})
if res.body
scb.call(res.body) # => this should be wrapped in some sort of
InvokeLater ?
else
ecb.call("getUsers failed") # => this too
end
end
end
I would prefer to use the Ruby standard library over the Java library.
Eager to learn,
Francis