Question

I'm trying:

request = WebRequest.Create( uri )
responseTask = request.GetResponseAsync
action = Action.new { process_request( sender, e ) }
task = Task.new( action )
responseTask.Wait( TimeSpan.new( -1 ) )
responseTask.ContinueWith( task )

But have following error:

can't convert System::Threading::Tasks::Task into System::Action[System::Threading::Tasks::Task] (TypeError)  

UPD

On

responseTask = request.GetResponseAsync  
action = Action[Task].new { process_request( sender, e ) }  
responseTask.Wait( TimeSpan.new( -1 ) )  
responseTask.ContinueWith( action )  

I'm getting this error:

Found multiple methods for 'ContinueWith': ContinueWith(System::Action[System::Threading::Tasks::Task]), ContinueWith(System::Action[System::Threading::Tasks::Task[System::Net::WebResponse]]) (System::Reflection::AmbiguousMatchException)
Was it helpful?

Solution

ContinueWith takes an

Action<Task> 

and has other overloads, but not for a Task.

eg:

action = Action.new {Console.WriteLine("action")}
task = Task.new( action )
action2 = Action[Task].new{Console.WriteLine("action2")}
task.ContinueWith(action2)
task.Start()
#prints "action" then "action2".

IronRuby may let you skip generic type specialisations That was the non-generic Task, here is the fully typed version for your problem:

 action = Action[Task[WebResponse]].new { process_request( sender, e ) }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top