0

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)
ostapische
  • 1,572
  • 2
  • 12
  • 26

1 Answers1

0

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 ) }
Max
  • 81
  • 1
  • 4
  • Can you show me working example? http://msdn.microsoft.com/ru-ru/library/system.threading.tasks.task(v=vs.110).aspx `Task` requieres `Action` for argument on initialization. `responseTask.ContinueWith( action )` get the same error. – ostapische Jul 31 '14 at 07:25
  • I'm try it but have an error, look at **UPD** section. – ostapische Jul 31 '14 at 11:20