WebRequest.getResponseasync에 대한 핸들러를 Ironruby에 설정하는 방법은 무엇입니까?

StackOverflow https://stackoverflow.com//questions/25013962

문제

나는 시도하고있다 :

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 )
.

그러나 다음과 같은 오류가 있습니다 :

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

UPD

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

이 오류가 발생했습니다 :

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)
.

도움이 되었습니까?

해결책

계속해서

Action<Task> 
.

및 다른 과부하가 있지만 작업은 아닙니다.

예 :

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는 일반적인 유형 전문화 의 일반적인 유형의 전문화를 건너 뛸 수 있습니다. 여기에는 문제가 완전히 입력 된 버전이 있습니다.

 action = Action[Task[WebResponse]].new { process_request( sender, e ) }
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top